|
Boost Users : |
Subject: Re: [Boost-users] Redefining new, to detect memory leaks, causes issues in boost
From: Lasse Laursen (gazoo_at_[hidden])
Date: 2013-05-10 03:22:43
Hey John,
Just wanted to thank you for the input.
I ended up partially relying on VLD. Although it, understandably,
detects a number of false positives via static objects that are left for
the OS to destroy.
Not really an optimal solution, but better than nothing, since I can
keep it off until I detect more leaks going off than usual...
Regards,
Lasse
On 12-04-2013 17:22, John Maddock wrote:
>> I recently upgraded to vs2012 and am making liberal use of its leak
>> detection described here:
>>
>> http://msdn.microsoft.com/en-us/library/x98tx3cf.aspx
>>
>> However, I'm running into a spot of trouble. I rely on the C++ style
>> new commands to allocate memory and as such, I make use of redefining
>> this call in order to get a specific file and line, at the end of my
>> programs execution, to where I allocated memory which is leaking. It's
>> super effective!
>>
>> According to the link above, the new command is to be redefined thusly:
>>
>> #ifdef _DEBUG
>> #ifndef DBG_NEW
>> #define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
>> #define new DBG_NEW
>> #endif
>> #endif // _DEBUG
>
> Which will break quite a bit of perfectly conforming C++ code :-(
>
> I use Visual Leak Detector: http://vld.codeplex.com/ which offers much
> better error reporting than MSVC's built in stuff and is still free.
>
> HTH, John.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net