开发者

C++ wxWidgets Gui-App stays in memory after closing it

The subject says it all. After i closed my app, it stays in the list of processes with some memory. I tried google perf tools and hours of debugging to find the leak.

Are there other tool开发者_如何学运维s to test it and find the problem?

Thank you.


My guess is that you have closed the top level window, and thus all its child windows, but you have not closed the app itself.

This does not happen if your program is arranged in a 'normal' way, but if you have, deliberately or by accident, used an unusual arrangement this can happen.

Fixing it, of course, depends on how exactly you have arranged your code. However, here is a suggestion to begin.

The usual way to close the app is to call wxApp::OnExit() which normally occurs when the top level window closes.

Do you have your own class, derived from wxApp? Do you have an override of OnExit()? If not, then make it so and use the debugger to check whether or not it is being called. If it is not being called, work out how to ensure that it is called.

Another idea: use the following to check that your top level window will close the app

bool wxApp::GetExitOnFrameDelete() const

Returns true if the application will exit when the top-level window is deleted, false otherwise.

If this return false, use the corresponding set to make it so.

A 3rd idea: The application will not exit while there are any top level windows open. So perhaps you have another top level window that is minimized or invisible but has not been closed? Any wxDialog or WxFrame or window derived from these is a top level window and will prevent the application from closing.

A 4th idea: Do you have any globals or attributes of the application object, whose destructors could enter an endless loop? These destructors are called after the windows are destroyed and if one of them does not return you would see the behaviour you describe.


You may try to look at wxWidget's sample folder. You'll find lots of small but complete applications that contain the full init/exit application cycle.

Inspect some samples and compare with your app's workflow.


Yes...problem solved. A TopLevelWindow that was not destroyed. A Memory Leak....stupid mistake.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜