0

I am new to MFC & I am maintaining a MFC Application, Which has a CView Window GUI for displaying and manipulating values of a Tree using CTreeCtrl. All my functionality are working fine but sometimes I am getting a crash. But still I can not identify any pattern for reason of the crash.

Sometimes after some common action like changing values (which I have already performed like 100 times & just worked fine) ,the application hangs or crashes; sometimes for maximizing after 10-15 minutes is causing this .Sometimes the tree text are getting weirdly bold in size and then hangs/crashes. Checking Call stack is of no use till now as it always points to DbgCRT or some internal MFC source files. It is an MDI application and I have noticed the crash happens when number of files are more or Current file has a large nested tree.

The main problem is I can not reproduce this bug at will. What I do is doing various actions with the tree like adding new nested branches, changing values & After 20-30 min of this crash may happen. Anyone please suggest any possible way of solution of this random occurring bug.

sample gui: http://postimg.org/image/6ed619voh/ "sample"

ADDITION: a snap after it was hanged : http://s7.postimg.org/dn216ufzf/crashtime_snap.png

4

1 回答 1

1

听起来您正在泄漏某种资源,很可能是 GDI 句柄。这些可能很难找到 - 您必须检查控件的每次使用(如CTreeCtrl、位图、句柄等),以确保您在适当的时间正确地释放它们(MSFT 文档在这里是必不可少的)。

  1. 可以提供帮助的一件事是在 Windows 中启动 TaskManager,并在您与应用程序交互时查看 GDI 对象列。如果句柄数一直在攀升,而您的应用逻辑认为不应该如此,那么它为您提供了一个开始寻找问题的地方。

  2. Visual Studio 调试器还将为您提供内存泄漏的线索。关闭您的应用程序(调试版本)时,请查看输出窗口。如果您正在泄漏,则输出窗口将显示指示内存泄漏的输出(例如:Detected memory leaks后跟地址和内存转储)。

  3. 此外,在 Visual Studio 调试器中运行您的构建(调试构建)。有时在运行时输出窗口中会有关于泄漏、内存覆盖等的线索。请注意这些。他们提供有价值的信息。干净的程序运行不会在输出窗口中出现警告、断言、泄漏等。

如果你有一个地方可以上传你的项目(不是太大),我会帮你看看。

勤奋和对细节的关注就是一切,在这里。

挂在那里!

于 2013-05-28T01:28:57.417 回答