Link to home
Start Free TrialLog in
Avatar of mamyun
mamyun

asked on

Using Debug Heap from C++

OK. I discovered this Debug Heap thing. it is awesome, but I am having problems using it with the new operator. When I use malloc and when there's a memory leak, the line number and filename of the allocation statement is correctly displayed. However, if I use new, the line number and filename ALWAYS point to crtdbg.h(552) which is where the new operator calls the debug version of new:
inline void* __cdecl operator new(unsigned int s)
        { return ::operator new(s, _NORMAL_BLOCK, __FILE__, __LINE__); }

Since the call is being made in the crtdbg.h file, the wrong line number and file is being recorded! Now, one might say that above, the operator new is declared inline, so the call should be replaced by the debug version of new. That doesn't seem to happen. I thought that probably expansion of inline functions is disabled in the DEBUG mode, so I turned it on from the project settings, but still, I get the wrong line number and file!
Please help, otherwise this GREAT feature will be useless to me!
ASKER CERTIFIED SOLUTION
Avatar of nietod
nietod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial