On Friday, 7 January 2022 at 20:33:05 UTC, eugene wrote:
* python guys have memory leaks
* js guys have memory leaks

GC isn't actually there to prevent memory leaks. Its main job is to guard against use-after-free memory corruption bugs.

Actually, technically, the paradigm is "infinite lifetime" and the garbage collection is just there as a practical matter because computers don't have infinite memory. They do a reasonably good job on memory leaks too, but that's not the main goal so they'd rather let memory leak than risk a use after free.

That's why D lets you do a hybrid approach easily: where the lifetime is trivial, you can easily do it yourself to optimize memory use. But when it isn't so obvious, you can use the GC to play it safe at the cost of a lil more memory use.

Reply via email to