mirror of https://github.com/buggins/dlangui.git
resource leak detection
This commit is contained in:
parent
e9636ea5f1
commit
342b736fbe
|
@ -346,3 +346,6 @@ void onResourceDestroyWhileShutdown(string resourceName, string objname = null)
|
||||||
Log.e("Resource leak: destroying resource while shutdown! ", resourceName, " ", objname);
|
Log.e("Resource leak: destroying resource while shutdown! ", resourceName, " ", objname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// set to true when exiting main - to detect destructor calls for resources by GC
|
||||||
|
__gshared bool APP_IS_SHUTTING_DOWN = false;
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,10 @@ class DrawBuf : RefCountedObject {
|
||||||
debug private static __gshared int _instanceCount;
|
debug private static __gshared int _instanceCount;
|
||||||
debug @property static int instanceCount() { return _instanceCount; }
|
debug @property static int instanceCount() { return _instanceCount; }
|
||||||
~this() {
|
~this() {
|
||||||
|
/*import core.memory : gc_inFinalizer;*/
|
||||||
|
if (APP_IS_SHUTTING_DOWN/* || gc_inFinalizer*/)
|
||||||
|
onResourceDestroyWhileShutdown("DrawBuf", this.classinfo.name);
|
||||||
|
|
||||||
debug _instanceCount--;
|
debug _instanceCount--;
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1605,5 +1605,3 @@ extern(C) void initResourceManagers();
|
||||||
extern (C) void initSharedResourceManagers();
|
extern (C) void initSharedResourceManagers();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -445,6 +445,7 @@ extern(C) int DLANGUImain(string[] args) {
|
||||||
releaseResourcesOnAppExit();
|
releaseResourcesOnAppExit();
|
||||||
|
|
||||||
Log.d("Exiting main");
|
Log.d("Exiting main");
|
||||||
|
APP_IS_SHUTTING_DOWN = true;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1805,6 +1805,7 @@ int sdlmain(string[] args) {
|
||||||
releaseResourcesOnAppExit();
|
releaseResourcesOnAppExit();
|
||||||
|
|
||||||
Log.d("Exiting main");
|
Log.d("Exiting main");
|
||||||
|
APP_IS_SHUTTING_DOWN = true;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -339,6 +339,11 @@ class Win32Window : Window {
|
||||||
|
|
||||||
~this() {
|
~this() {
|
||||||
debug Log.d("Window destructor");
|
debug Log.d("Window destructor");
|
||||||
|
if (_drawbuf) {
|
||||||
|
destroy(_drawbuf);
|
||||||
|
_drawbuf = null;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
static if (ENABLE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
import derelict.opengl3.wgl;
|
import derelict.opengl3.wgl;
|
||||||
|
@ -1262,6 +1267,11 @@ int myWinMain(void* hInstance, void* hPrevInstance, char* lpCmdLine, int iCmdSho
|
||||||
releaseResourcesOnAppExit();
|
releaseResourcesOnAppExit();
|
||||||
|
|
||||||
Log.d("Exiting main");
|
Log.d("Exiting main");
|
||||||
|
APP_IS_SHUTTING_DOWN = true;
|
||||||
|
import core.memory : GC;
|
||||||
|
Log.d("Calling GC.collect");
|
||||||
|
GC.collect();
|
||||||
|
Log.e("Non-zero DrawBuf instance count when exiting: ", DrawBuf.instanceCount);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue