3 ms·
I agree, that should count as memory leak. If we're wrongfully retaining an object long after it should have been deallocated, that's a memory leak. The particu
by MaxBarraclough 6y ago
I agree, that should count as memory leak. If we're wrongfully retaining an object long after it should have been deallocated, that's a memory leak. The particulars of the language and the memory-management strategy, aren't the point.
I disagree though that memory leaks are common in Java programs. Again though I don't know of a quantitative study on this, unfortunately.
> The effect is using manyX more memory than even the leaky C program
That will depend on the programs.
> very hard to find and fix
I can't comment from experience, but I can believe this.
> Malloc leaks are trivial to locate with valgrind, so for practical purposes they don't even exist, in the wild, in programs under any kind of maintenance.
This is false. Issues with memory management are responsible for many real-world security issues with C code. https://www.zdnet.com/article/microsoft-70-percent-of-all-security-bugs-are-memory-safety-issues/ https://www.zdnet.com/article/microsoft-70-percent-of-all-se...
- ncmncm 6y agoThose are not leaks.
- MaxBarraclough 6y agoTrue. I wasn't able to find a good source on how common memory leaks are in modern C code. Do you have one? I'd be surprised if memory leaks are far less common than double-free, use-after-free, dereferencing NULL, and out-of-bounds access. I'd expect they'd be roughly equally difficult to detect, either manually or using tooling like Valgrind and static-analysers. I'd also expect memory-leaks to be of generally less concern, and therefore less 'newsworthy', as a small memory leak isn't as likely to pose a real problem as any of the other errors.
- ncmncm 6y agoYes, double-free and use-after-free are no end of trouble in C programs (and, incidentally, vanishingly rare in C++ programs), but this thread is specifically about leaks in C and in GC languages (and which are also vanishingly rare in C++ programs).