Home » U++ Library support » U++ Library : Other (not classified elsewhere) » exit() -> heap leaks detected.
exit() -> heap leaks detected. [message #17996] |
Fri, 05 September 2008 22:23  |
captainc
Messages: 278 Registered: December 2006 Location: New Jersey, USA
|
Experienced Member |
|
|
Why does exit() cause a heap leak when Vector class has items?
Example:
CONSOLE_APP_MAIN
{
Vector<String> v1;
v1.Add("hello");
exit(1);
}
|
|
|
Re: exit() -> heap leaks detected. [message #17997 is a reply to message #17996] |
Fri, 05 September 2008 23:00   |
mr_ped
Messages: 826 Registered: November 2005 Location: Czech Republic - Praha
|
Experienced Contributor |
|
|
Maybe "exit" does not call some destructors? Try to exit cleanly.
To set the exit value with clean finish you can use: (to see if it helps)
BTW, what version of UPP and what compiler?
The leak detection should work ok just with the MSC. ( )
[Updated on: Fri, 05 September 2008 23:00] Report message to a moderator
|
|
|
Re: exit() -> heap leaks detected. [message #17998 is a reply to message #17997] |
Fri, 05 September 2008 23:15   |
captainc
Messages: 278 Registered: December 2006 Location: New Jersey, USA
|
Experienced Member |
|
|
SetExitCode() does not perform the exit operation also.
My compiler is Linux GCC 4.1.3, but it also happens with MSC8.
Upp SVN.324
I first encountered it when trying to use another C++ library that called exit(). I can control the exit path on my application, but I don't want to have to modify other libs. I partially wrote the command line processor package for this reason.
[Updated on: Fri, 05 September 2008 23:16] Report message to a moderator
|
|
|
Re: exit() -> heap leaks detected. [message #17999 is a reply to message #17998] |
Fri, 05 September 2008 23:44   |
mr_ped
Messages: 826 Registered: November 2005 Location: Czech Republic - Praha
|
Experienced Contributor |
|
|
captainc wrote on Fri, 05 September 2008 23:15 | SetExitCode() does not perform the exit operation also.
|
I was sort of trying to write that, but reading my post again ... and it's far from obvious.
Well, I was unable to make leak detection work in 2008.1 with GCC (MINGW too). I mean, I forced it to run and collect data, but the init of U++ itself did leak always. Maybe the SVN version is fixed a bit in this manner?
I can't follow the SVN, I need very stable code base for my purposes, and I don't have spare time to try it in other directory right now. :/
Are you sure the Vector is leaking? When you remove the Vector stuff, does it leak or not? (and you can use the memory breakpoint feature to break at the leaking alloc ... although debugging with GCC is total pain, I rather add some LOG here/there to avoid debugging with U++, it's so bad. :/
[Updated on: Fri, 05 September 2008 23:46] Report message to a moderator
|
|
|
|
|
|
Re: exit() -> heap leaks detected. [message #18003 is a reply to message #18001] |
Sat, 06 September 2008 08:39   |
 |
mirek
Messages: 14255 Registered: November 2005
|
Ultimate Member |
|
|
captainc wrote on Fri, 05 September 2008 18:39 | From definition of exit function:
Quote: | Terminates the process normally, performing the regular cleanup for terminating processes.
First, all functions registered by calls to atexit are executed in the reverse order of their registration. Then, all streams are closed and the temporary files deleted, and finally the control is returned to the host environment.
|
This is why I have been confused. Is the definition not consistent with the actions? I guess I did not research it enough... neither did a few library authors!
|
Well, global destructors are registred via atexit (usually, it is). Anyway, "exit" never returns, means nothing can be called at the end of block.
OTOH, as system usually performs necessarry cleanup (closing file handles etc...), I can see that some C++ library calls exit, not caring about leaks. But that is not really correct in my book.
Mirek
|
|
|
|
Re: exit() -> heap leaks detected. [message #18010 is a reply to message #18004] |
Sat, 06 September 2008 13:25  |
captainc
Messages: 278 Registered: December 2006 Location: New Jersey, USA
|
Experienced Member |
|
|
Quote: | IMO, you cannot solve the problem without altering the library code (maybe you should complain to the author
|
Yeah, I really don't like the fact that they call exit instead of throwing an exception. I would rather alter it or find some other way.
|
|
|
Goto Forum:
Current Time: Sun Apr 27 12:55:48 CEST 2025
Total time taken to generate the page: 0.00731 seconds
|