Home » U++ TheIDE » U++ TheIDE: Compiling, Linking, Debugging of your packages » Getting "heap leaks detected!" error messages on program exit. How to debug it?
Re: Getting "heap leaks detected!" error messages on program exit. How to debug it? [message #3986 is a reply to message #3980] |
Thu, 13 July 2006 18:04 |
|
mirek
Messages: 13980 Registered: November 2005
|
Ultimate Member |
|
|
Well, hunting memory leaks is always troublesome, that is why you should hunt one as soon as possible
Now if heap leak manifests when connecting to external library, it is even more puzzling... (have you any 'new' in your code?)
Anyway, for U++ based code, I usually start with looking at log file, which dumps all leaks. Quite often you can tell what the leak is just examining it.
If that does not help, there is one ugly hack in heap code - you can add "memory-watch" into your APP_MAIN to catch the allocation that returns the address the leaks. (see Core/dbgheap.cpp for details - you place breakpoint there to catch). That of course helps only as long as leaking allocation for the specific address is the first one...
Then of course, if everything else fails, I usually start to "minimize" code, removing part after part until leak goes away (then the bug is in the part I removed).
Hopefuly, not considering the low level stuff, leak incidence in U++ is low. Hint: The most common cause of memory leak in my code is missing virtual destructor in the base class...
Mirek
|
|
|
Goto Forum:
Current Time: Sun May 19 12:23:11 CEST 2024
Total time taken to generate the page: 0.00884 seconds
|