M
Morten Aune Lyrstad
Ok, now I'm officially confused. I have a large project going, which
uses a win32 ui library I am developing myself. And I'm getting weird
memory leaks. I don't know if I can explain what is going on, but I
really need some help on this one.
Ok, so I have this class defined (written by Randy Charles Morin,
www.kbcafe.com) which detects memory leaks. It creates a memory check
point in the constructor, and another in the destructor, and then
compares the two to find differences. When I want to test for memory
leaks I make a variable with this type at the global level (before
everything else). My thinking is the first-in last-out thing with
constructors and destructors. The first thing to be called would be this
object's constructor, and the last thing would be the destructor. Am I
right?
Ok; so my application Main looks like this:
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, char
*lpCmdLine, int nCmdShow)
{
CWin32Application *app;
app = MemNew CWin32Application();
int ret = __Win32_RunMainApp(app, hInstance, hPrevInstance, lpCmdLine,
nCmdShow);
app->Destroy();
MemDelete app;
return ret;
}
Never mind the weird __Win32_RunMainApp, it's really just a temporary
throw-in which collects the command line and runs a Main function in
CWin32Application. I will change this to the better, I swear!
Ok, so the application is allocated, and a function is run which creates
windows, menus, toolbars, controls, documents etc etc etc. Here comes
the weird parts: If I place the control destruction calls in the
destructor of CWin32Application, or in the function "Destroy" as you see
above (app->Destroy()), I get a memory leak. But if I put it in the code
which is called on the win32 message WM_DESTROY, I get NO memory leaks.
What the (insert curse word here) is going on? I'm not really allowed to
put their destruction calls in the WM_DESTROY function, so I can't use
that as a solution. As far as I know, every destruction function for
every control is actually called, I've stepped through the call. Still
memory leaks gets reported.
For the record, I also tried placing the memory leak class variable
within the WinMain itself, but it gave me exactly the same results.
I must admit, I will be very impressed if any of you can help me with
this, but I'm desperate.
Yours,
Morten Aune Lyrstad
uses a win32 ui library I am developing myself. And I'm getting weird
memory leaks. I don't know if I can explain what is going on, but I
really need some help on this one.
Ok, so I have this class defined (written by Randy Charles Morin,
www.kbcafe.com) which detects memory leaks. It creates a memory check
point in the constructor, and another in the destructor, and then
compares the two to find differences. When I want to test for memory
leaks I make a variable with this type at the global level (before
everything else). My thinking is the first-in last-out thing with
constructors and destructors. The first thing to be called would be this
object's constructor, and the last thing would be the destructor. Am I
right?
Ok; so my application Main looks like this:
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, char
*lpCmdLine, int nCmdShow)
{
CWin32Application *app;
app = MemNew CWin32Application();
int ret = __Win32_RunMainApp(app, hInstance, hPrevInstance, lpCmdLine,
nCmdShow);
app->Destroy();
MemDelete app;
return ret;
}
Never mind the weird __Win32_RunMainApp, it's really just a temporary
throw-in which collects the command line and runs a Main function in
CWin32Application. I will change this to the better, I swear!
Ok, so the application is allocated, and a function is run which creates
windows, menus, toolbars, controls, documents etc etc etc. Here comes
the weird parts: If I place the control destruction calls in the
destructor of CWin32Application, or in the function "Destroy" as you see
above (app->Destroy()), I get a memory leak. But if I put it in the code
which is called on the win32 message WM_DESTROY, I get NO memory leaks.
What the (insert curse word here) is going on? I'm not really allowed to
put their destruction calls in the WM_DESTROY function, so I can't use
that as a solution. As far as I know, every destruction function for
every control is actually called, I've stepped through the call. Still
memory leaks gets reported.
For the record, I also tried placing the memory leak class variable
within the WinMain itself, but it gave me exactly the same results.
I must admit, I will be very impressed if any of you can help me with
this, but I'm desperate.
Yours,
Morten Aune Lyrstad