|
Boost Users : |
Subject: Re: [Boost-users] Redefining new, to detect memory leaks, causes issues in boost
From: John Maddock (boost.regex_at_[hidden])
Date: 2013-04-12 04:22:00
> 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