Click here to Skip to main content
15,889,281 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to get hWnd in MFC? Pin
prasad_som20-May-07 20:16
prasad_som20-May-07 20:16 
QuestionPolygons / PtInRegion Pin
m.dietz20-May-07 6:49
m.dietz20-May-07 6:49 
Question_CrtSetBreakAlloc does nothing! Pin
dum20-May-07 6:37
dum20-May-07 6:37 
AnswerRe: _CrtSetBreakAlloc does nothing! Pin
Mark Salsbery20-May-07 7:09
Mark Salsbery20-May-07 7:09 
GeneralRe: _CrtSetBreakAlloc does nothing! Pin
dum20-May-07 8:50
dum20-May-07 8:50 
GeneralRe: _CrtSetBreakAlloc does nothing! Pin
Mark Salsbery20-May-07 9:04
Mark Salsbery20-May-07 9:04 
QuestionRe: _CrtSetBreakAlloc does nothing! Pin
dum20-May-07 9:47
dum20-May-07 9:47 
AnswerRe: _CrtSetBreakAlloc does nothing! Pin
Mark Salsbery20-May-07 11:00
Mark Salsbery20-May-07 11:00 
Hmm i don't know...

First, where are you putting the _CrtSetBreakAlloc() call? You'll want that as early in the
program execution as possible. If you still can't get it to break when you set
_CrtSetBreakAlloc() at the start of Main/WinMain (or your CWinApp constructor in MFC) then maybe
the allocation is occuring in a DLL.

Second, to get more detailed info (file/linenumber where allocation occurred):

Add this to your precompiled header .h file:

#ifdef _DEBUG
#include <crtdbg.h>
#define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
#else
#define DEBUG_NEW new
#endif

For non-MFC apps add this to the top of ALL your source modules, under the
last #include... line:

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

For an MFC app (as I mentioned before) add this to the top of ALL your source modules, under the
last #include... line:

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

I personally use these in EVERY file. The time it's saved me in debugging leaks has been HUGE
compared to the time it took to add these lines to hundreds of source files.


This link may help further: Memory Leak Detection Enabling[^]

Mark


"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

GeneralRe: _CrtSetBreakAlloc does nothing! Pin
dum20-May-07 14:08
dum20-May-07 14:08 
GeneralRe: _CrtSetBreakAlloc does nothing! Pin
Nibu babu thomas20-May-07 19:19
Nibu babu thomas20-May-07 19:19 
AnswerRe: _CrtSetBreakAlloc does nothing! Pin
Gary R. Wheeler20-May-07 14:04
Gary R. Wheeler20-May-07 14:04 
Questionreturn program Pin
KARFER20-May-07 6:25
KARFER20-May-07 6:25 
AnswerRe: return program Pin
Mark Salsbery20-May-07 6:35
Mark Salsbery20-May-07 6:35 
AnswerRe: return program Pin
Hamid_RT20-May-07 7:33
Hamid_RT20-May-07 7:33 
Questionreturn program Pin
KARFER20-May-07 6:21
KARFER20-May-07 6:21 
AnswerRe: return program Pin
Hamid_RT20-May-07 7:35
Hamid_RT20-May-07 7:35 
AnswerRe: return program Pin
Moonis Ahmed20-May-07 20:30
Moonis Ahmed20-May-07 20:30 
QuestionInfo on one process Pin
nofearxd20-May-07 5:47
nofearxd20-May-07 5:47 
AnswerRe: Info on one process Pin
Mark Salsbery20-May-07 6:30
Mark Salsbery20-May-07 6:30 
AnswerRe: Info on one process Pin
Hamid_RT20-May-07 7:53
Hamid_RT20-May-07 7:53 
QuestionMFC resizing OpenGL Pin
zqueezy20-May-07 2:27
zqueezy20-May-07 2:27 
AnswerRe: MFC resizing OpenGL Pin
zqueezy20-May-07 2:37
zqueezy20-May-07 2:37 
GeneralRe: MFC resizing OpenGL Pin
Hans Dietrich20-May-07 5:26
mentorHans Dietrich20-May-07 5:26 
QuestionHow do I create a CBitmap from raw data in memory? Pin
fixitnow20-May-07 2:25
fixitnow20-May-07 2:25 
AnswerRe: How do I create a CBitmap from raw data in memory? Pin
Mark Salsbery20-May-07 6:48
Mark Salsbery20-May-07 6:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.