|
|
Home » U++ TheIDE » U++ TheIDE: Compiling, Linking, Debugging of your packages » Getting "heap leaks detected!" error messages on program exit. How to debug it?
Getting "heap leaks detected!" error messages on program exit. How to debug it? [message #3980] |
Thu, 13 July 2006 14:52 |
battika
Messages: 4 Registered: July 2006 Location: Budapest, Hungary
|
Junior Member |
|
|
Sorry for the rather noobish question I'm still familiarizing myself with U++.
I'd like to connect to a Postgres database from the latest Ulimate++ running on Red Hat Linux ES 4 (Nahant) and just downloaded the precompiled libpqxx Postgres files to give them a go. I've managed to set up the connection to the Postgres server but upon program exit I always get a "heap leak detected!" error message". Even when I build an empty console project with libqxx.so linked I get the same message. Can you give me pointer where I should start looking at this issue, and is it an issue anyway?
Thanks in advance.
|
|
|
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: 13975 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
|
|
|
Re: Getting "heap leaks detected!" error messages on program exit. How to debug it? [message #3995 is a reply to message #3986] |
Thu, 13 July 2006 22:44 |
battika
Messages: 4 Registered: July 2006 Location: Budapest, Hungary
|
Junior Member |
|
|
Hi Mirek,
First of all, thank you for your prompt and detailed answer. I hope you're still not running out of patience as I have some more comments.
Quote: | Now if heap leak manifests when connecting to external library, it is even more puzzling... (have you any 'new' in your code?)
|
Actually I started off with a "core console project". Included the Postgres library header files and added the library to the linker. Now if I comment out *everything* so only the CONSOLE_APP_MAIN section remains with the #include statement and attempt to run the program I get the same error message. So to answer your question I don't have any new()'s in my code since I don't have a code
Quote: | 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.
|
Thank you for the tip. Again, sorry for the question but can you tell me where the log is normally located (Linux)?
Quote: | 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...
|
Cool, I will do that.
Quote: | 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).
|
My code is already minimized . Probably it's time to have a look at the third-party header files.
Thanks a lot for your help again.
|
|
|
|
|
|
Goto Forum:
Current Time: Fri Mar 29 10:29:34 CET 2024
Total time taken to generate the page: 0.01516 seconds
|
|
|