digitalmars.D.bugs - [Issue 1551] New: 80kb memory leak with DLLs
- d-bugmail puremagic.com (55/55) Oct 07 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1551
http://d.puremagic.com/issues/show_bug.cgi?id=1551 Summary: 80kb memory leak with DLLs Product: D Version: 1.022 Platform: PC OS/Version: Windows Status: NEW Severity: minor Priority: P4 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: thecybershadow gmail.com Loading a bare-bones DLL and unloading it leaves a memory leak. === DLL source === import std.c.windows.windows; import std.stdio; // see bug #1550 HINSTANCE g_hInst; extern (C) { void gc_init(); void gc_term(); void _minit(); void _moduleCtor(); void _moduleUnitTests(); } extern (Windows) BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved) { switch (ulReason) { case DLL_PROCESS_ATTACH: gc_init(); // initialize GC _minit(); // initialize module list _moduleCtor(); // run module constructors _moduleUnitTests(); // run module unit tests break; case DLL_PROCESS_DETACH: _fcloseallp = null; // see bug #1550 gc_term(); // shut down GC break; case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: // Multiple threads not supported yet return false; } g_hInst=hInstance; return true; } === end of DLL source === After loading, the process' "private bytes" figure grows by 204-220 KB. After the DLL is unloaded, only 128-132 KB is freed, leaking about 76 KB of memory every time. I have eliminated other factors (a link in the loader) by using a DLL compiled in another language with the same loader test program. --
Oct 07 2007