From d5f0bd35394198c8fd3452c29c16109e05209ae8 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Thu, 30 Sep 2021 10:38:18 +0200 Subject: memory: Added experimental mimalloc path to AlignedAllocImpl/AlignedFreeImpl Also added similar path to IoBuffer Cannot be enabled at the moment as we end up passing pointers to std::free via some path so more work will be necessary --- zencore/memory.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'zencore/memory.cpp') diff --git a/zencore/memory.cpp b/zencore/memory.cpp index 613b6ba67..da78ae3a8 100644 --- a/zencore/memory.cpp +++ b/zencore/memory.cpp @@ -6,6 +6,7 @@ #ifdef ZEN_PLATFORM_WINDOWS # include +# include #else # include #endif @@ -18,8 +19,11 @@ static void* AlignedAllocImpl(size_t size, size_t alignment) { #if ZEN_PLATFORM_WINDOWS - // return _aligned_malloc(size, alignment); // MSVC alternative - return _mm_malloc(size, alignment); +# if ZEN_USE_MIMALLOC && 0 /* this path is not functional */ + return mi_aligned_alloc(alignment, size); +# else + return _aligned_malloc(size, alignment); +# endif #else // posix_memalign(&Ret, Alignment, Size); // Apple, AndroidApi<28 return std::aligned_alloc(alignment, size); @@ -33,8 +37,11 @@ AlignedFreeImpl(void* ptr) return; #if ZEN_PLATFORM_WINDOWS - // _aligned_free(ptr); MSVC alternative - _mm_free(ptr); +# if ZEN_USE_MIMALLOC && 0 /* this path is not functional */ + return mi_free(ptr); +# else + _aligned_free(ptr); +# endif #else // free(ptr) // Apple :) std::free(ptr); -- cgit v1.2.3