Visual Studio 2008 输出窗口停止工作

发布于 2024-12-05 13:34:44 字数 202 浏览 4 评论 0原文

我在 VS 2008 中从事 C++ 项目已经有一段时间了。直到最近,在终止我的应用程序时,输出窗口会显示是否有任何内存泄漏。然而,几天前我注意到它停止显示这些有价值的信息。我还尝试抛出一些 printf() ,但输出窗口也没有显示。

我猜我在某个地方改变了偏好,但我似乎找不到它。现在所有输出显示的是它已加载/卸载的 dll。有什么想法吗?

谢谢, 麦克风

i've been working on a C++ project for some time now in VS 2008. Until recently, upon terminating my application the output window would show if i had any memory leaks. however, a few days ago i noticed it stopped showing this valuable information. i also tried throwing some printf() around, but the output window isn't showing that either.

i'm guessing i changed a preference somewhere, but i can't seem to find it. all the output shows now is which dll's it has loaded/unloaded. any ideas?

thanks,
mike

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撩动你心 2024-12-12 13:34:44

根据我自己的经验,内存泄漏输出丢失可能是由于不同的原因造成的。总结最重要的内容:

  1. 源代码中的更改:

    • 禁用内存泄漏报告(即使用_CrtSetDbgFlag )
    • 安装自定义报告挂钩(请参阅 _CrtSetReportHook、 _CrtSetReportHook2)
    • 将输出重定向到文件(请参阅 CrtSetReportMode
    • 源代码中的更改导致应用程序终止时无声“崩溃” - 应用程序在到达报告内存泄漏的点之前无声地终止,没有任何问题迹象(因为这似乎不太可能,我曾经遇到过这种情况) .
  2. 开发环境中的设置导致输出重定向到另一个窗口。一种可能是:工具\选项\调试\常规\将所有输出窗口文本重定向到立即窗口(从底部数第五个)。这里可能还存在其他可能性。

我想排除第 2 点的一种可能性是在 (main.cpp) 行中创建一个简单的控制台应用程序:

#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>

#ifndef DEBUG_NEW
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#define new DEBUG_NEW
#endif

int _tmain(int argc, _TCHAR* argv[])
{
    int nOldState = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
    _CrtSetDbgFlag(nOldState | _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);

    int *pInt = new int[100];
    return 0;
}

如果正确运行此应用程序会输出内存泄漏,那么不幸的是您可能会遇到情况 1

当然,我排除了明显的情况输出可能消失的原因(其中一些已经在评论中提到)。

From my own experience, the memory leak output gone missing can be due to different reasons. to summarize the most important ones:

  1. Changes in the source code that:

    • disable memory leak reporting (i.e. using _CrtSetDbgFlag)
    • install custom report hooks (see _CrtSetReportHook, _CrtSetReportHook2)
    • redirect the output to a file (see CrtSetReportMode
    • changes in the source code that lead to silent "crashes" on application termination - the application silently terminates without any indication of a problem before reaching the point where the memory leaks are reported (as improbable this might seem I had this once).
  2. Settings in the development environment cause the output to be redirected to another window. One possibility would be: Tools \ Options \ Debugging \ General \ Redirect all Output Window text to the Immediate Window (the fifth from bottom). Probably other possibilities exist here.

I guess one possibility to rule out point 2 would be to create a simple console application in the lines of (main.cpp):

#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>

#ifndef DEBUG_NEW
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#define new DEBUG_NEW
#endif

int _tmain(int argc, _TCHAR* argv[])
{
    int nOldState = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
    _CrtSetDbgFlag(nOldState | _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);

    int *pInt = new int[100];
    return 0;
}

If running this application correctly outputs memory leaks then unfortunately you are probably in case 1

Of course I ruled out the obvious things why the output could be gone (some of them already mentioned in the comments).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文