Are there any programming languages/runtimes/frameworks with a "garbage collection" strategy of just never collecting any garbage? (During program execution; obviously the memory would be freed when the process exited)

It wouldn't work for _most_ use cases, but for extremely short lived programs (e.g. CLI scripts) it seems like this would be an easy way to avoid the stop-the-world costs of a GC without any memory safety risks.

Does this exist? Or am I missing some reason it'd be dumb?

@codesections HotSpot JVM also has a noop GC (openjdk.java.net/jeps/318) for, likewise, short-lived programs (even though the startup cost is unlikely to make that an attractive first choice.)

Not sure many consider PHP particularly worthy of discussion, but even though it's reference counted by default, the cycle collector can be toggled when needed: php.net/manual/en/features.gc.
Same (in both regards) applies to Python too: docs.python.org/3/library/gc.h

So perhaps it's more common than it may seem at first?

Follow

@paulsnar

> So perhaps [a noop GC for short-lived programs is] more common than it may seem at first?

Yeah, that's my overall takeaway from the many interesting examples people have brought up in the replies!

Sign in to participate in the conversation
Fosstodon

Fosstodon is an English speaking Mastodon instance that is open to anyone who is interested in technology; particularly free & open source software.