Browse Source

Minor refactoring & fix a mem leak

Panagiotis Christopoulos Charitos 4 years ago
parent
commit
eb25d9a843

+ 1 - 1
AnKi/Core/App.cpp

@@ -330,7 +330,7 @@ Error App::initInternal(const ConfigSet& config_, AllocAlignedCallback allocCb,
 	m_displayStats = config.getNumberU32("core_displayStats");
 
 	initMemoryCallbacks(allocCb, allocCbUserData);
-	m_heapAlloc = HeapAllocator<U8>(m_allocCb, m_allocCbData);
+	m_heapAlloc = HeapAllocator<U8>(m_allocCb, m_allocCbData, "Core");
 
 	ANKI_CHECK(initDirs(config));
 

+ 1 - 1
AnKi/Core/ConfigSet.cpp

@@ -66,7 +66,7 @@ public:
 
 ConfigSet::ConfigSet()
 {
-	m_alloc = HeapAllocator<U8>(allocAligned, nullptr);
+	m_alloc = HeapAllocator<U8>(allocAligned, nullptr, "ConfigSet");
 
 #define ANKI_CONFIG_OPTION(name, ...) newOption(ANKI_STRINGIZE(name), __VA_ARGS__);
 #include <AnKi/Core/ConfigDefs.h>

+ 1 - 1
AnKi/Core/DeveloperConsole.cpp

@@ -22,7 +22,7 @@ DeveloperConsole::~DeveloperConsole()
 
 Error DeveloperConsole::init(AllocAlignedCallback allocCb, void* allocCbUserData, ScriptManager* scriptManager)
 {
-	m_alloc = HeapAllocator<U8>(allocCb, allocCbUserData);
+	m_alloc = HeapAllocator<U8>(allocCb, allocCbUserData, "DeveloperConsole");
 	zeroMemory(m_inputText);
 
 	ANKI_CHECK(m_manager->newInstance(m_font, "EngineAssets/UbuntuMonoRegular.ttf", Array<U32, 1>{16}));

+ 1 - 1
AnKi/Core/NativeWindowAndroid.cpp

@@ -9,7 +9,7 @@ namespace anki {
 
 Error NativeWindow::newInstance(const NativeWindowInitInfo& initInfo, NativeWindow*& nativeWindow)
 {
-	HeapAllocator<U8> alloc(initInfo.m_allocCallback, initInfo.m_allocCallbackUserData);
+	HeapAllocator<U8> alloc(initInfo.m_allocCallback, initInfo.m_allocCallbackUserData, "NativeWindow");
 	NativeWindowAndroid* sdlwin = alloc.newInstance<NativeWindowAndroid>();
 
 	sdlwin->m_alloc = alloc;

+ 1 - 1
AnKi/Core/NativeWindowSdl.cpp

@@ -13,7 +13,7 @@ namespace anki {
 
 Error NativeWindow::newInstance(const NativeWindowInitInfo& initInfo, NativeWindow*& nativeWindow)
 {
-	HeapAllocator<U8> alloc(initInfo.m_allocCallback, initInfo.m_allocCallbackUserData);
+	HeapAllocator<U8> alloc(initInfo.m_allocCallback, initInfo.m_allocCallbackUserData, "NativeWindow");
 	NativeWindowSdl* sdlwin = alloc.newInstance<NativeWindowSdl>();
 
 	sdlwin->m_alloc = alloc;

+ 2 - 0
AnKi/Gr/Vulkan/GpuMemoryManager.cpp

@@ -63,6 +63,8 @@ void GpuMemoryManagerInterface::freeChunk(GpuMemoryManagerChunk* chunk)
 
 	ANKI_ASSERT(m_allocatedMemory >= chunk->m_size);
 	m_allocatedMemory -= chunk->m_size;
+
+	m_parent->m_alloc.deleteInstance(chunk);
 }
 
 GpuMemoryManager::~GpuMemoryManager()

+ 1 - 1
AnKi/Gr/Vulkan/GrManager.cpp

@@ -33,7 +33,7 @@ GrManager::~GrManager()
 
 Error GrManager::newInstance(GrManagerInitInfo& init, GrManager*& gr)
 {
-	auto alloc = HeapAllocator<U8>(init.m_allocCallback, init.m_allocCallbackUserData);
+	auto alloc = HeapAllocator<U8>(init.m_allocCallback, init.m_allocCallbackUserData, "Gr");
 
 	GrManagerImpl* impl = alloc.newInstance<GrManagerImpl>();
 

+ 1 - 1
AnKi/Input/InputAndroid.cpp

@@ -14,7 +14,7 @@ Error Input::newInstance(AllocAlignedCallback allocCallback, void* allocCallback
 {
 	ANKI_ASSERT(allocCallback && nativeWindow);
 
-	HeapAllocator<U8> alloc(allocCallback, allocCallbackUserData);
+	HeapAllocator<U8> alloc(allocCallback, allocCallbackUserData, "Input");
 	InputAndroid* ainput =
 		static_cast<InputAndroid*>(alloc.getMemoryPool().allocate(sizeof(InputAndroid), alignof(InputAndroid)));
 	::new(ainput) InputAndroid();

+ 1 - 1
AnKi/Input/InputSdl.cpp

@@ -36,7 +36,7 @@ Error Input::newInstance(AllocAlignedCallback allocCallback, void* allocCallback
 {
 	ANKI_ASSERT(allocCallback && nativeWindow);
 
-	HeapAllocator<U8> alloc(allocCallback, allocCallbackUserData);
+	HeapAllocator<U8> alloc(allocCallback, allocCallbackUserData, "Input");
 	InputSdl* sdlinput = static_cast<InputSdl*>(alloc.getMemoryPool().allocate(sizeof(InputSdl), alignof(InputSdl)));
 	::new(sdlinput) InputSdl(alloc);
 

+ 1 - 1
AnKi/Renderer/MainRenderer.cpp

@@ -34,7 +34,7 @@ Error MainRenderer::init(ThreadHive* hive, ResourceManager* resources, GrManager
 {
 	ANKI_R_LOGI("Initializing main renderer");
 
-	m_alloc = HeapAllocator<U8>(allocCb, allocCbUserData);
+	m_alloc = HeapAllocator<U8>(allocCb, allocCbUserData, "MainRenderer");
 	m_frameAlloc = StackAllocator<U8>(allocCb, allocCbUserData, 1024 * 1024 * 10, 1.0f);
 
 	// Init renderer and manipulate the width/height

+ 2 - 1
AnKi/ShaderCompiler/ShaderProgramCompiler.cpp

@@ -21,7 +21,8 @@ Error ShaderProgramBinaryWrapper::serializeToFile(CString fname) const
 
 	BinarySerializer serializer;
 	HeapAllocator<U8> tmpAlloc(m_alloc.getMemoryPool().getAllocationCallback(),
-							   m_alloc.getMemoryPool().getAllocationCallbackUserData());
+							   m_alloc.getMemoryPool().getAllocationCallbackUserData(),
+							   "ShaderProgramBinaryWrapper temp");
 	ANKI_CHECK(serializer.serialize(*m_binary, tmpAlloc, file));
 
 	return Error::NONE;

+ 1 - 2
AnKi/Util/Allocator.h

@@ -89,9 +89,8 @@ public:
 			ANKI_UTIL_LOGF("Out of memory");
 		}
 
-		::new(m_pool) TPool();
+		::new(m_pool) TPool(allocCb, allocCbUserData, std::forward<TArgs>(args)...);
 
-		m_pool->init(allocCb, allocCbUserData, std::forward<TArgs>(args)...);
 		m_pool->getRefcount().store(1);
 	}
 

+ 1 - 0
AnKi/Util/BuddyAllocatorBuilder.inl.h

@@ -108,6 +108,7 @@ void BuddyAllocatorBuilder<T_MAX_MEMORY_RANGE_LOG2, TLock>::free(Address address
 		for(const FreeList& freeList : m_freeLists)
 		{
 			ANKI_ASSERT(freeList.getSize() == 0);
+			(void)freeList;
 		}
 	}
 }

+ 48 - 79
AnKi/Util/Memory.cpp

@@ -141,19 +141,32 @@ void* allocAligned(void* userData, void* ptr, PtrSize size, PtrSize alignment)
 	return out;
 }
 
-BaseMemoryPool::~BaseMemoryPool()
+BaseMemoryPool::BaseMemoryPool(Type type, AllocAlignedCallback allocCb, void* allocCbUserData, const char* name)
+	: m_allocCb(allocCb)
+	, m_allocCbUserData(allocCbUserData)
+	, m_type(type)
 {
-	ANKI_ASSERT(m_refcount.load() == 0 && "Refcount should be zero");
+	ANKI_ASSERT(allocCb == nullptr);
+
+	I64 len;
+	if(name && (len = strlen(name)) > 0)
+	{
+		m_name = static_cast<char*>(malloc(len + 1));
+		memcpy(m_name, name, len + 1);
+	}
 }
 
-Bool BaseMemoryPool::isInitialized() const
+BaseMemoryPool::~BaseMemoryPool()
 {
-	return m_allocCb != nullptr;
+	ANKI_ASSERT(m_refcount.load() == 0 && "Refcount should be zero");
 }
 
-HeapMemoryPool::HeapMemoryPool()
-	: BaseMemoryPool(Type::HEAP)
+HeapMemoryPool::HeapMemoryPool(AllocAlignedCallback allocCb, void* allocCbUserDataconst, const char* name)
+	: BaseMemoryPool(Type::HEAP, allocCb, allocCbUserDataconst, name)
 {
+#if ANKI_MEM_EXTRA_CHECKS
+	m_signature = computePoolSignature(this);
+#endif
 }
 
 HeapMemoryPool::~HeapMemoryPool()
@@ -161,28 +174,13 @@ HeapMemoryPool::~HeapMemoryPool()
 	const U32 count = m_allocationCount.load();
 	if(count != 0)
 	{
-		ANKI_UTIL_LOGW("Memory pool destroyed before all memory being released "
-					   "(%u deallocations missed)",
-					   count);
+		ANKI_UTIL_LOGW("Memory pool destroyed before all memory being released (%u deallocations missed): %s", count,
+					   getName());
 	}
 }
 
-void HeapMemoryPool::init(AllocAlignedCallback allocCb, void* allocCbUserData)
-{
-	ANKI_ASSERT(!isInitialized());
-	ANKI_ASSERT(m_allocCb == nullptr);
-	ANKI_ASSERT(allocCb != nullptr);
-
-	m_allocCb = allocCb;
-	m_allocCbUserData = allocCbUserData;
-#if ANKI_MEM_EXTRA_CHECKS
-	m_signature = computePoolSignature(this);
-#endif
-}
-
 void* HeapMemoryPool::allocate(PtrSize size, PtrSize alignment)
 {
-	ANKI_ASSERT(isInitialized());
 #if ANKI_MEM_EXTRA_CHECKS
 	ANKI_ASSERT(alignment <= MAX_ALIGNMENT && "Wrong assumption");
 	size += ALLOCATION_HEADER_SIZE;
@@ -213,8 +211,6 @@ void* HeapMemoryPool::allocate(PtrSize size, PtrSize alignment)
 
 void HeapMemoryPool::free(void* ptr)
 {
-	ANKI_ASSERT(isInitialized());
-
 	if(ANKI_UNLIKELY(ptr == nullptr))
 	{
 		return;
@@ -269,26 +265,15 @@ void StackMemoryPool::StackAllocatorBuilderInterface::recycleChunk(Chunk& chunk)
 	invalidateMemory(&chunk.m_memoryStart[0], chunk.m_chunkSize);
 }
 
-StackMemoryPool::StackMemoryPool()
-	: BaseMemoryPool(Type::STACK)
+StackMemoryPool::StackMemoryPool(AllocAlignedCallback allocCb, void* allocCbUserData, PtrSize initialChunkSize,
+								 F64 nextChunkScale, PtrSize nextChunkBias, Bool ignoreDeallocationErrors,
+								 U32 alignmentBytes, const char* name)
+	: BaseMemoryPool(Type::STACK, allocCb, allocCbUserData, name)
 {
-}
-
-StackMemoryPool::~StackMemoryPool()
-{
-}
-
-void StackMemoryPool::init(AllocAlignedCallback allocCb, void* allocCbUserData, PtrSize initialChunkSize,
-						   F64 nextChunkScale, PtrSize nextChunkBias, Bool ignoreDeallocationErrors, U32 alignmentBytes)
-{
-	ANKI_ASSERT(!isInitialized());
-	ANKI_ASSERT(allocCb);
 	ANKI_ASSERT(initialChunkSize > 0);
 	ANKI_ASSERT(nextChunkScale >= 1.0);
 	ANKI_ASSERT(alignmentBytes > 0 && alignmentBytes <= MAX_ALIGNMENT);
 
-	m_allocCb = allocCb;
-	m_allocCbUserData = allocCbUserData;
 	m_builder.getInterface().m_parent = this;
 	m_builder.getInterface().m_alignmentBytes = alignmentBytes;
 	m_builder.getInterface().m_ignoreDeallocationErrors = ignoreDeallocationErrors;
@@ -297,10 +282,12 @@ void StackMemoryPool::init(AllocAlignedCallback allocCb, void* allocCbUserData,
 	m_builder.getInterface().m_nextChunkBias = nextChunkBias;
 }
 
-void* StackMemoryPool::allocate(PtrSize size, PtrSize alignment)
+StackMemoryPool::~StackMemoryPool()
 {
-	ANKI_ASSERT(isInitialized());
+}
 
+void* StackMemoryPool::allocate(PtrSize size, PtrSize alignment)
+{
 	Chunk* chunk;
 	PtrSize offset;
 	if(m_builder.allocate(size, alignment, chunk, offset))
@@ -315,8 +302,6 @@ void* StackMemoryPool::allocate(PtrSize size, PtrSize alignment)
 
 void StackMemoryPool::free(void* ptr)
 {
-	ANKI_ASSERT(isInitialized());
-
 	if(ANKI_UNLIKELY(ptr == nullptr))
 	{
 		return;
@@ -330,43 +315,19 @@ void StackMemoryPool::free(void* ptr)
 
 void StackMemoryPool::reset()
 {
-	ANKI_ASSERT(isInitialized());
 	m_builder.reset();
 	m_allocationCount.store(0);
 }
 
-ChainMemoryPool::ChainMemoryPool()
-	: BaseMemoryPool(Type::CHAIN)
-{
-}
-
-ChainMemoryPool::~ChainMemoryPool()
-{
-	if(m_allocationCount.load() != 0)
-	{
-		ANKI_UTIL_LOGW("Memory pool destroyed before all memory being released");
-	}
-
-	Chunk* ch = m_headChunk;
-	while(ch)
-	{
-		Chunk* next = ch->m_next;
-		destroyChunk(ch);
-		ch = next;
-	}
-}
-
-void ChainMemoryPool::init(AllocAlignedCallback allocCb, void* allocCbUserData, PtrSize initialChunkSize,
-						   F32 nextChunkScale, PtrSize nextChunkBias, PtrSize alignmentBytes)
+ChainMemoryPool::ChainMemoryPool(AllocAlignedCallback allocCb, void* allocCbUserData, PtrSize initialChunkSize,
+								 F32 nextChunkScale, PtrSize nextChunkBias, PtrSize alignmentBytes, const char* name)
+	: BaseMemoryPool(Type::CHAIN, allocCb, allocCbUserData, name)
 {
-	ANKI_ASSERT(!isInitialized());
 	ANKI_ASSERT(initialChunkSize > 0);
 	ANKI_ASSERT(nextChunkScale >= 1.0);
 	ANKI_ASSERT(alignmentBytes > 0);
 
 	// Set all values
-	m_allocCb = allocCb;
-	m_allocCbUserData = allocCbUserData;
 	m_alignmentBytes = alignmentBytes;
 	m_initSize = initialChunkSize;
 	m_scale = nextChunkScale;
@@ -383,10 +344,24 @@ void ChainMemoryPool::init(AllocAlignedCallback allocCb, void* allocCbUserData,
 	}
 }
 
-void* ChainMemoryPool::allocate(PtrSize size, PtrSize alignment)
+ChainMemoryPool::~ChainMemoryPool()
 {
-	ANKI_ASSERT(isInitialized());
+	if(m_allocationCount.load() != 0)
+	{
+		ANKI_UTIL_LOGW("Memory pool destroyed before all memory being released");
+	}
 
+	Chunk* ch = m_headChunk;
+	while(ch)
+	{
+		Chunk* next = ch->m_next;
+		destroyChunk(ch);
+		ch = next;
+	}
+}
+
+void* ChainMemoryPool::allocate(PtrSize size, PtrSize alignment)
+{
 	Chunk* ch;
 	void* mem = nullptr;
 
@@ -422,8 +397,6 @@ void* ChainMemoryPool::allocate(PtrSize size, PtrSize alignment)
 
 void ChainMemoryPool::free(void* ptr)
 {
-	ANKI_ASSERT(isInitialized());
-
 	if(ANKI_UNLIKELY(ptr == nullptr))
 	{
 		return;
@@ -452,8 +425,6 @@ void ChainMemoryPool::free(void* ptr)
 
 PtrSize ChainMemoryPool::getChunksCount() const
 {
-	ANKI_ASSERT(isInitialized());
-
 	PtrSize count = 0;
 	Chunk* ch = m_headChunk;
 	while(ch)
@@ -467,8 +438,6 @@ PtrSize ChainMemoryPool::getChunksCount() const
 
 PtrSize ChainMemoryPool::getAllocatedSize() const
 {
-	ANKI_ASSERT(isInitialized());
-
 	PtrSize sum = 0;
 	Chunk* ch = m_headChunk;
 	while(ch)

+ 30 - 29
AnKi/Util/Memory.h

@@ -95,6 +95,12 @@ public:
 		return m_allocationCount.load();
 	}
 
+	/// Get the name of the pool.
+	const char* getName() const
+	{
+		return (m_name) ? m_name : "Unamed";
+	}
+
 protected:
 	/// Pool type.
 	enum class Type : U8
@@ -114,18 +120,16 @@ protected:
 	/// Allocations count.
 	Atomic<U32> m_allocationCount = {0};
 
-	BaseMemoryPool(Type type)
-		: m_type(type)
-	{
-	}
-
-	/// Check if already created.
-	Bool isInitialized() const;
+	/// Construct it.
+	BaseMemoryPool(Type type, AllocAlignedCallback allocCb, void* allocCbUserData, const char* name);
 
 private:
 	/// Refcount.
 	Atomic<U32> m_refcount = {0};
 
+	/// Optional name.
+	char* m_name = nullptr;
+
 	/// Type.
 	Type m_type = Type::NONE;
 };
@@ -135,8 +139,11 @@ private:
 class HeapMemoryPool final : public BaseMemoryPool
 {
 public:
-	/// Default constructor.
-	HeapMemoryPool();
+	/// Construct it.
+	/// @param allocCb The allocation function callback.
+	/// @param allocCbUserData The user data to pass to the allocation function.
+	/// @param name An optional name.
+	HeapMemoryPool(AllocAlignedCallback allocCb, void* allocCbUserDataconst, const char* name = nullptr);
 
 	/// Destroy
 	~HeapMemoryPool();
@@ -164,15 +171,6 @@ private:
 class StackMemoryPool final : public BaseMemoryPool
 {
 public:
-	/// The type of the pool's snapshot
-	using Snapshot = void*;
-
-	/// Default constructor
-	StackMemoryPool();
-
-	/// Destroy
-	~StackMemoryPool();
-
 	/// Init with parameters.
 	/// @param allocCb The allocation function callback.
 	/// @param allocCbUserData The user data to pass to the allocation function.
@@ -182,9 +180,13 @@ public:
 	/// @param ignoreDeallocationErrors Method free() may fail if the ptr is not in the top of the stack. Set that to
 	///        true to suppress such errors.
 	/// @param alignmentBytes The maximum supported alignment for returned memory.
-	void init(AllocAlignedCallback allocCb, void* allocCbUserData, PtrSize initialChunkSize, F64 nextChunkScale = 2.0,
-			  PtrSize nextChunkBias = 0, Bool ignoreDeallocationErrors = true,
-			  U32 alignmentBytes = ANKI_SAFE_ALIGNMENT);
+	/// @param name An optional name.
+	StackMemoryPool(AllocAlignedCallback allocCb, void* allocCbUserData, PtrSize initialChunkSize,
+					F64 nextChunkScale = 2.0, PtrSize nextChunkBias = 0, Bool ignoreDeallocationErrors = true,
+					U32 alignmentBytes = ANKI_SAFE_ALIGNMENT, const char* name = nullptr);
+
+	/// Destroy
+	~StackMemoryPool();
 
 	/// Allocate aligned memory.
 	/// @param size The size to allocate.
@@ -296,12 +298,6 @@ private:
 class ChainMemoryPool final : public BaseMemoryPool
 {
 public:
-	/// Default constructor
-	ChainMemoryPool();
-
-	/// Destroy
-	~ChainMemoryPool();
-
 	/// Init the pool.
 	/// @param allocCb The allocation function callback.
 	/// @param allocCbUserData The user data to pass to the allocation function.
@@ -309,8 +305,13 @@ public:
 	/// @param nextChunkScale Value that controls the next chunk.
 	/// @param nextChunkBias Value that controls the next chunk.
 	/// @param alignmentBytes The maximum supported alignment for returned memory.
-	void init(AllocAlignedCallback allocCb, void* allocCbUserData, PtrSize initialChunkSize, F32 nextChunkScale = 2.0,
-			  PtrSize nextChunkBias = 0, PtrSize alignmentBytes = ANKI_SAFE_ALIGNMENT);
+	/// @param name An optional name.
+	ChainMemoryPool(AllocAlignedCallback allocCb, void* allocCbUserData, PtrSize initialChunkSize,
+					F32 nextChunkScale = 2.0, PtrSize nextChunkBias = 0, PtrSize alignmentBytes = ANKI_SAFE_ALIGNMENT,
+					const char* name = nullptr);
+
+	/// Destroy
+	~ChainMemoryPool();
 
 	/// Allocate memory. This operation is thread safe
 	/// @param size The size to allocate

+ 1 - 1
AnKi/Util/System.cpp

@@ -152,7 +152,7 @@ void* getAndroidCommandLineArguments(int& argc, char**& argv)
 	jstring jsParam1 = static_cast<jstring>(env->CallObjectMethod(intent, gseid, env->NewStringUTF("cmd")));
 
 	// Parse the command line args
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
+	HeapAllocator<U8> alloc(allocAligned, nullptr, "getAndroidCommandLineArguments temp");
 	StringListAuto args(alloc);
 
 	if(jsParam1)

+ 7 - 23
Tests/Util/Memory.cpp

@@ -14,8 +14,7 @@ ANKI_TEST(Util, HeapMemoryPool)
 {
 	// Simple
 	{
-		HeapMemoryPool pool;
-		pool.init(allocAligned, nullptr);
+		HeapMemoryPool pool(allocAligned, nullptr);
 
 		void* ptr = pool.allocate(123, 1);
 		ANKI_TEST_EXPECT_NEQ(ptr, nullptr);
@@ -25,8 +24,7 @@ ANKI_TEST(Util, HeapMemoryPool)
 
 	// Simple array
 	{
-		HeapMemoryPool pool;
-		pool.init(allocAligned, nullptr);
+		HeapMemoryPool pool(allocAligned, nullptr);
 
 		void* ptr = pool.allocate(2, 1);
 		ANKI_TEST_EXPECT_NEQ(ptr, nullptr);
@@ -39,21 +37,12 @@ ANKI_TEST(Util, StackMemoryPool)
 {
 	// Create/destroy test
 	{
-		StackMemoryPool pool;
-	}
-
-	// Create/destroy test #2
-	{
-		StackMemoryPool pool;
-
-		pool.init(allocAligned, nullptr, 10);
+		StackMemoryPool pool(allocAligned, nullptr, 10);
 	}
 
 	// Allocate
 	{
-		StackMemoryPool pool;
-
-		pool.init(allocAligned, nullptr, 100, 1.0, 0, true);
+		StackMemoryPool pool(allocAligned, nullptr, 100, 1.0, 0, true);
 
 		void* a = pool.allocate(25, 1);
 		ANKI_TEST_EXPECT_NEQ(a, nullptr);
@@ -92,7 +81,7 @@ ANKI_TEST(Util, StackMemoryPool)
 
 	// Parallel
 	{
-		StackMemoryPool pool;
+		StackMemoryPool pool(allocAligned, nullptr, 100, 1.0, 0, true);
 		const U THREAD_COUNT = 32;
 		const U ALLOC_SIZE = 25;
 		ThreadPool threadPool(THREAD_COUNT);
@@ -116,7 +105,6 @@ ANKI_TEST(Util, StackMemoryPool)
 			}
 		};
 
-		pool.init(allocAligned, nullptr, 100, 1.0, 0, true);
 		Array<AllocateTask, THREAD_COUNT> tasks;
 
 		for(U32 i = 0; i < THREAD_COUNT; ++i)
@@ -175,9 +163,7 @@ ANKI_TEST(Util, ChainMemoryPool)
 	// Basic test
 	{
 		const U size = 8;
-		ChainMemoryPool pool;
-
-		pool.init(allocAligned, nullptr, size, 2.0, 0, 1);
+		ChainMemoryPool pool(allocAligned, nullptr, size, 2.0, 0, 1);
 
 		void* mem = pool.allocate(5, 1);
 		ANKI_TEST_EXPECT_NEQ(mem, nullptr);
@@ -193,9 +179,7 @@ ANKI_TEST(Util, ChainMemoryPool)
 	// Basic test 2
 	{
 		const U size = sizeof(PtrSize) + 10;
-		ChainMemoryPool pool;
-
-		pool.init(allocAligned, nullptr, size, 2.0, 0, 1);
+		ChainMemoryPool pool(allocAligned, nullptr, size, 2.0, 0, 1);
 
 		void* mem = pool.allocate(size, 1);
 		ANKI_TEST_EXPECT_NEQ(mem, nullptr);