Intentional memory leaks
groups.google.com
groups.google.com
But when the mission of the code expands beyond the original use case, this element might be lost. It's best to encode these limitations/constraints into the design of the program, whenever possible. However for this case I cannot imagine how to do that. When that's impossible, it's ideal to advertise these limitations as a design feature coupled with the intended use cases. Therein lies the only hope of discovering this before it causes problems.
These days, the vast, vast majority of our code can and should undergo unit testing and have sanitizer tests enabled for that unit testing. We should be extremely cautious about whitelisting/bypassing those checks (but at least those are more explicit signals).
I concur. I've heard this story a number of times, and it smells like a myth.
Well, maybe terrain recognition navigation system might need to allocate memory. Or perhaps a data link for processing commands. But probably not.
Funny, though.
I also saw this strategy used in coursework. I was in graduate school, and I had just done the Compiler class the previous semester. My best friends were taking the course, and the professor had concocted a home made leak checker and foisted it on the class, declaring that no program with leaks would be accepted for the final project. It was only a few weeks before the end of the term, and everyone was demoralized. Jokingly, I suggested that everyone just make their own mechanism of the same kind, which would track allocations then release all of the program's allocated memory just before the prof's leak checker ran. As it turns out, the whole class ended up implementing my idea. The test data was small enough, that everyone's compilers could afford to simply leak memory, then release it all at the end. Problem solved.
It was one struct instead of separate globals because of some coding style guide at the time.
"But what if we want to use this in a library?" "Here's all the data in one container, malloc it and use that."
I don't think many of those programs ever did end up in libraries.
> if I see a malloc for a bunch of memory intended for the
> lifetime of the app and it's at the beginning of main and
> then it doesn't get freed before the end of process
> execution it's not really a memory leak in my book.
Not freeing such memory and otherwise not explicitly destroying all your state can hide bugs, hide legitimate leaks, and add noise to memory profilers like valgrind. Destroying your state exercises those code pathways, which is very valuable.Plus, it's just a good habit in a language with manual memory management. It's like wearing your seatbelt--if it's a habit you just do it as a matter of course without thought, no matter whether you're driving around the block or across the country. You start making exceptions, you break the habit, you invite errors of judgment.
However, a real memory leak, to me, is memory that gets allocated at different times through the lifetime of the app and doesn't get reliably freed do to unexpected code paths or race conditions. If I don't see the allocation count rise steadily while I run my app I'm not as worried.
I don't think the project ever got anywhere, but back then, your KDE desktop spent a good 15-30 seconds carefully deallocating all objects.
In fact, it's entire flight time could be a few seconds. Imagine an air-to-air missile fired by an aircraft at another aircraft.
adding memory: $xxx per missile paying a software engineer to fix a memory leak: $x,xxx,xxx
Paying the software engineer would be a fraction of the cost to fix the memory leak in software. Recertification of the software would blow it all away.
It seems like those shouldn't be coupled, but I seem to remember (horror) stories about programs running on machines with segmented memory, where the segments straddled each other, and/or where the last segment wrapped around to the beginning of RAM. Expanding RAM in such a scenario would cause wrapped writes to no longer wrap, for example.
Or any other illogical reason a program could use or abuse the size of RAM for. It just never ceases to amaze me how things that should be completely decoupled can end up not being.
> blow it all away
I appreciated the wording there. :)
This makes me wonder, will self-driving cars need recertification if even one line of code is touched?
Missing (1995) on the title, and perhaps a [Usenet] tag?