Thread overview | |||||
---|---|---|---|---|---|
|
July 08, 2007 gc_term() memory leaking. | ||||
---|---|---|---|---|
| ||||
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; } |
July 08, 2007 Re: gc_term() memory leaking. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Neal Alexander | > 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
|
July 09, 2007 Re: gc_term() memory leaking. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Findlay | Paul Findlay wrote:
>> 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
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.
|
Copyright © 1999-2021 by the D Language Foundation