开发者

visual studio 2008 output window stopped working

开发者 https://www.devze.com 2023-04-06 04:56 出处:网络
i\'ve been working on a C++ project for some time now in VS 2008.Until recently, upon terminating my a开发者_运维技巧pplication the output window would show if i had any memory leaks.however, a few da

i've been working on a C++ project for some time now in VS 2008. Until recently, upon terminating my a开发者_运维技巧pplication 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


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

0

精彩评论

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

关注公众号