Comment #0 by dlang-bugzilla — 2007-10-07T16:45:48Z
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.
Comment #1 by razvan.nitu1305 — 2019-08-27T07:35:05Z
Is this bug still valid in D2? I don't have a windows machine to test it.
Comment #2 by razvan.nitu1305 — 2019-10-24T09:29:17Z
This issue is marked as D1. Closing as D1 is no longer supported. If this issue manifests in D2 please reopen.