visual studio 2008 output window stopped working

混江龙づ霸主 提交于 2019-12-24 10:13:01

问题


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


回答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).



来源:https://stackoverflow.com/questions/7479344/visual-studio-2008-output-window-stopped-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!