Are memory leaks ever ok?

Posted by Imbue on Stack Overflow See other posts from Stack Overflow or by Imbue
Published on 2008-11-07T19:01:52Z Indexed on 2010/05/01 19:37 UTC
Read the original article Hit count: 183

Filed under:
|
|
|

Is it ever acceptable to have a memory leak in your C or C++ application?

What if you allocate some memory and use it until the very last line of code in your application (for example, a global object's deconstructor)? As long as the memory consumption doesn't grow over time, is it OK to trust the OS to free your memory for you when your application terminates (on Windows, Mac, and Linux)? Would you even consider this a real memory leak if the memory was being used continuously until it was freed by the OS.

What if a third party library forced this situation on you? Would refuse to use that third party library no matter how great it otherwise might be?

I only see one practical disadvantage, and that is that these benign leaks will show up with memory leak detection tools as false positives.

© Stack Overflow or respective owner

Related posts about memory-leaks

Related posts about c++