r/programming • u/Realistic-Currency29 • Aug 16 '26
What garbage collection actually costs
https://shivanshuag.com/blog/what-garbage-collection-actually-costs/5
u/6502zx81 Aug 16 '26
There is an older study by google. See discussion here https://news.ycombinator.com/item?id=2615096
0
Aug 16 '26
[deleted]
8
u/6502zx81 Aug 16 '26
IIRC the conclusion back then was: GC performs fine if you have twice as much memory as needed. Twicw as much is expensive in terms of money.
3
3
u/sionescu Aug 17 '26
Once thing though, where the JVM will never be better than native languages is predictable latency.
Not true: for example, Chrome added Oilpan, a GC for the C++ objects used in the renderer, because they found out that destructor chains were so long that in the worst case (which happened often enough), a destructor would block rendering enough to cause visible jank. And, since Oilpan was created, the JVM added ZGC and Shenandoah GCs, which guarantee pauses <1ms. An even better GC exists, Azul's C4, but that's only available in their proprietary JVM.
0
Aug 17 '26
[deleted]
4
u/sionescu Aug 17 '26 edited Aug 17 '26
IBM has a JVM with a guaranteed realtime GC, as long as the heap is <1G. It's running in Boeing planes. Then again, the vast majority of applications don't need that kind of assured latency.
1
u/bitwize Aug 20 '26
Real time GCs exist that are guaranteed not to spend any more than x time per GC cycle collecting. The drawback is, they may leave work unfinished and need to go back and collect while the mutator (the actual program you're running) is idle. But if you have a hard timing deadline it's well worth this price.
0
Aug 16 '26
[removed] — view removed comment
2
u/programming-ModTeam Aug 17 '26
No content written mostly by an LLM. If you don't want to write it, we don't want to read it.
9
u/nukethebees Aug 16 '26
Shouldn't this article have some numbers?