4 ms·
Defragmentation is one benefit of garbage collected environments I feel like you don't see mentioned often. Every collector I can think of is capable of compact
by kevingadd 6y ago
Defragmentation is one benefit of garbage collected environments I feel like you don't see mentioned often. Every collector I can think of is capable of compacting its heap so that you are less likely to suffer from fragmentation overhead, and it happens as part of the regular GC flow (though typically not the 'fast' collections) instead of being something you have to go out of your way to trigger at ideal times.
Obviously there are downsides to GC, but it's interesting to see how in this scenario malloc+free had the same "uses way more memory than strictly necessary" problem that people usually pin on garbage collectors.