Comment by willis936

4 days ago

>Consider this, if the mod interface was C/C++, do you think those poorly optimized mods could be trusted to also not leak memory?

Of course. Because they would fail loudly and would have to be fixed in order to run. Garbage collection is a crutch which lets broken things appear not broken.

Memory leaks very often don't fail loudly. Especially if they are slower leaks which don't immediately break the application.

A lot of the memory problems that you can see without a GC are hard to find and diagnose. Use after free, for example, is very often safe. It only crashes or causes problems sometimes. Same for double free. And they are hard to diagnose because the problems they do create are often observed at a distance. Use after free will silently corrupt some bit of memory somewhere else, what trips up on it might be completely unrelated.

It's the opposite of failing loudly.

  • > A lot of the memory problems that you can see without a GC are hard to find and diagnose

    The nastiest leak I've ever seen in a C++ production system happened inside the allocator. We had a really hostile allocation pattern that forced the book-keeping structures inside the allocator to grow over time.

    • To be fair, I've seen something similar with the JVM, though it recovers. G1GC when it was first introduced would create these massive bookkeeping structures in order to run collections. We are talking about off JVM heap memory allocations up to 20% of the JVM heap allocation.

      It's since gotten a lot better with JVM updates, so much so that it's not a problem in Java 21 and 25.