Re: Memory leaks




On 9 Feb 2011, at 11:13, Tor Lillqvist wrote:

Each time you call _CrtDumpMemoryLeaks() it dumps all the memory that's been allocated but not yet 
released.

So it doesn't take into consideration at all whether the memory in
question is / can be used or not, i.e. whether there is any pointer to
it in local variables, etc. All memory that has not been released is a
"leak"?

In your program, you don't normally call _CrtDumpMemoryLeaks() at all (although it's available if you want to 
do so).  Normally though, you leave this to the debugger which calls it when your program closes.  In that 
way, it lists all the memory that got allocated (by the program) but not released (by the program).


Does it make sense for a library to spend significant amount of time
(potentially paging in pages that have otherwise been stale for ages)
when the using process is about to exit, just to "free" memory, that
will be truly freed by the OS anyway

If there's a benefit, yes.  In this case the benefit is that it would make it easier to find genuine memory 
leaks.


With the right tool there is no problem at all in finding such "true"
leaks. On Windows, I guess it could be Purify?

It's certainly worth trying but in my experience, third party analysis tools are rarely better than those 
built into my IDE (even though they might be more extensive).  If there's an evaluation version though, I'll 
give it a try and see how it performs.  Thanks for the suggestion.

John


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]