From ff8adf7b45121aada0b4f4403b0f45a6e2dfe475 Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 19 Feb 2018 13:00:51 -0500 Subject: Fix IR memory leaks. 1, make IRModule class own a memory pool for all IR object allocations 2. For now, we allow IR objects to own other (externally) heap allocated objects, such as String, List and RefPtrs by tracking all IR objects that has been allocated for the IRModule in a list named `IRModule::irObjectsToFree`. and call destructor for all these objects upon the destruction of the IRModule. In the long term, we should eliminate the use of all these externally allocated types in IR system and get rid of this tracking and explicit destructor calls. 3. remove non-generic `createValueImpl` functions and retain only generic versions in IRBulider so we can properly call the constructor of the IR types to set up virtual tables correctly for destructor dispatching. 4. add `MemoryPool` class for allocation of the IR objects. 5. Make sure we are disposing IRSpecContexts when we are done with the specialized IR module. 6. Add `_CrtDumpMemoryLeaks()` calls to check memory leaks upon destruction of a Slang session. If we are to support multiple sessions at a time, this call should probably be replaced with the more advanced MemoryState versions of the memory leak checker. --- source/slang/slang.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/slang/slang.cpp') diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 4238681f3..0f5d8e17a 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -751,6 +751,9 @@ SLANG_API void spDestroySession( { if(!session) return; delete SESSION(session); +#ifdef _MSC_VER + _CrtDumpMemoryLeaks(); +#endif } SLANG_API void spAddBuiltins( -- cgit v1.2.3