使用调试器运行时,MFC程序的行为有所不同 [英] MFC Program Behaves Different When Running With Debugger

查看:102
本文介绍了使用调试器运行时,MFC程序的行为有所不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现MFC应用程序的发行版存在问题,但是如果我尝试在使用调试器运行时重现该问题,永远不会发生.  为什么调试版本与发布版本可能会有所不同?

I found an issue with the release build of my MFC application but if I try to recreate the issue when running with the debugger the problem never occurs.  Since it never happens when running the debugger I can’t find the exact cause of the issue in the release build.  Why might the debug build work differently to the release build?  Is there any way I can make the debug build work the same as the release build so I can recreate the issue?

在其他问题上;当我运行程序的发行版时,它将使用大约25MB的内存,无论运行多长时间,内存都保持恒定.  该程序处理数据流,因此它使内存使用量每秒增加约50Kb.  这是大量的内存使用情况,还是调试器的正常副作用,还是出了问题?

On other question; when I run the release version of my program it uses about 25MB of memory which stays fairly constant no matter how long it runs.  However, when I run the debug version it starts off using about 40MB of RAM but this gradually grows until it reaches 1.2GB after six hours.  The program processes a data stream and as it does so memory usage grows by about 50Kb per second.  Even with the data stream disconnected simply redrawing the windows causes memory usage to increase by a few kilobytes and this memory is never freed.  Is this considerable memory usage and a normal side effect of the debugger or is something going wrong?  Are there any settings that can be used to reduce the memory usage when debugging?

感谢您对这些问题的帮助.

推荐答案

Hello Craig000,

Hello Craig000,

感谢您在此处发布帖子.

Thanks for your post here.

是的,Debug和Release版本之间有一些区别,在这两种模式下,某些类(例如,字符串类)的实现方式有所不同.请查看此博客以获取更多信息: http://blogs .msdn.com/xiangfan/archive/2008/08/30/debug-vs-release.aspx .但是,不幸的是,我没有找到可以使设置在Visual Studio IDE中相同的开关和标志.

You are right, there is a little difference between Debug and Release build, Some classes (for example, string class) were implemented differently in these two modes. Please take a look at this blog for more information: http://blogs.msdn.com/xiangfan/archive/2008/08/30/debug-vs-release.aspx. However, unfortunately, I did not find and switches/flags that could make the setting the same in Visual Studio IDE.

由于运行该程序时内存会增加,因此建议您检测是否存在内存泄漏.为了检测MFC中的内存泄漏,我们可以使用MFC内置的宏和函数.请看一下这篇文章,它可能会对您有所帮助: http://msdn. microsoft.com/en-us/library/c99kz476(VS.80).aspx .您还可以使用其他工具(例如WinDbg.exe)来诊断内存泄漏问题: http://www.codeproject .com/KB/cpp/MemoryLeak.aspx

Since the memory grows when running the program, I suggest you detect if there are memory leaks. To detect memory leaks in MFC, we could use macros and functions built in with MFC. Please take a look at this article, it may help you: http://msdn.microsoft.com/en-us/library/c99kz476(VS.80).aspx. You could also use other tools (like WinDbg.exe) to diagnose the memory leak issue: http://www.codeproject.com/KB/cpp/MemoryLeak.aspx

最诚挚的问候


这篇关于使用调试器运行时,MFC程序的行为有所不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆