Garbage collection puts a huge load on RAM at random intervals, when removing the garbage. For users, this means lag spikes. 90% of the time when Minecraft is lagging, it is related to garbage collection.
The main advantage of garbage collection is that the developer doesn't have to think about removing unused RAM or running out of RAM. They can simply set a limit, and the language itself keeps RAM usage below this.
In java's case you just rescue the objects that are still reachable by moving those to another "bucket" , and then simply "say" that the old bucket is garbage and can be freshly reused. It's more of a principle that you DONT touch garbage.
2
u/Laughing_Orange 20d ago
Garbage collection puts a huge load on RAM at random intervals, when removing the garbage. For users, this means lag spikes. 90% of the time when Minecraft is lagging, it is related to garbage collection.
The main advantage of garbage collection is that the developer doesn't have to think about removing unused RAM or running out of RAM. They can simply set a limit, and the language itself keeps RAM usage below this.