logoalt Hacker News

aleph_minus_onetoday at 3:31 PM1 replyview on HN

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

Garbage collection does not solve memory leak problems. For example

- keeping a reference too long,

- much more subtle: having a reference to some object inside some closure

will also cause memory leaks in a garbage-collected language.

The proper solution is to consider what you name "poorly optimized mods" to be highly experimental (only those who are of very high quality can be treated differently).


Replies

cogman10today at 5:00 PM

> Garbage collection does not solve memory leak problems

It solves a class of memory leak problems which are much harder to address without the GC. Memory lifetimes.

It's true that you can still create an object that legitimately lives for the duration of the application, nothing solves that.

But what you can't do is allocate something on the heap and forget to free it. Or double free it. Or free it before the actual lifetime has finished.

Those are much trickier problems to solve which experienced C/C++ programmers trip over all the time. It's hard enough to have been the genesis of languages like Java and Rust.