3 ms·
There is a whole class of memory leaks that is possible in C but not in Java. You can leak memory by forgetting to deallocate it. This class is not possible in
by alephnil 12y ago
There is a whole class of memory leaks that is possible in C but not in Java. You can leak memory by forgetting to deallocate it. This class is not possible in typical Java code, because the garbage collector collects it.
Then you have memory leaks that happens because the application has data structures that grow unbounded. The latter one is not really preventable by automatic means, because the memory is still referenced from elsewhere in the application, and a garbage collector can't know that this memory won't be accessed again.
It does help that the most common source of memory leaks is eliminated however. That many Java applications are memory hogs is more a result of typical Java programming style than anything else.
- exabrial 12y agoThat comment was meant as a joke, hence why I used the smilee..... Sheesh HN
- mercurial 12y ago> It does help that the most common source of memory leaks is eliminated however. That many Java applications are memory hogs is more a result of typical Java programming style than anything else. This may be part of it, but typically, the JVM will happily reclaim large chunks of memory from the OS, without necessarily allocating anything internally.