digitalmars.D.learn - gc_term() memory leaking.
- Neal Alexander (24/24) Jul 07 2007 Is there any way to force a GC instance in a DLL to free the heap pages
- Paul Findlay (3/5) Jul 07 2007 Tango's gc_term() call's a destructor which frees the calloc'ed heap.
- Neal Alexander (10/17) Jul 08 2007 Alright, well i added this to src/phobos/internal/gc.d and rebuilt phobo...
Is there any way to force a GC instance in a DLL to free the heap pages allocated by gc_init? gc_term()is just an alias to fullCollectNoStack(). the following DLL leaks around 1,000-2,000K each time the dll is reloaded. extern (Windows): BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved) { g_hInst = hInstance; switch (ulReason){ case DLL_PROCESS_ATTACH: gc_init(); _minit(); _moduleCtor(); activate(); break; case DLL_PROCESS_DETACH: _moduleDtor(); gc_term(); break; case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: return false; } return TRUE; }
Jul 07 2007
Is there any way to force a GC instance in a DLL to free the heap pages allocated by gc_init? gc_term()is just an alias to fullCollectNoStack().Tango's gc_term() call's a destructor which frees the calloc'ed heap. But sorry, I don't know much more than that.. - Paul
Jul 07 2007
Paul Findlay wrote:Alright, well i added this to src/phobos/internal/gc.d and rebuilt phobos.lib. extern (C) void gc_destroy(){ _gc.Dtor(); } And added gc_destroy() to the unload section of DllMain. Looks like it solved the problem somewhat - it only leaks 100kb now when the DLL reloads instead of 1.5mb. That 100kb could easily be the fault of my program too; i'm not sure atm. Should i file a bug report about this or what? Its possible gc_term()'s behavior has been the same ever since the start. I'm using DMD2.02 if i haven't mentioned it already.Is there any way to force a GC instance in a DLL to free the heap pages allocated by gc_init? gc_term()is just an alias to fullCollectNoStack().Tango's gc_term() call's a destructor which frees the calloc'ed heap. But sorry, I don't know much more than that.. - Paul
Jul 08 2007