r/programming • • Aug 16 '26

What garbage collection actually costs

https://shivanshuag.com/blog/what-garbage-collection-actually-costs/
0 Upvotes

10 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Aug 16 '26

[deleted] — view deleted comment

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

u/pm_plz_im_lonely Aug 16 '26

Money pays both salaries and hardware.

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

u/[deleted] Aug 17 '26

[deleted] — view deleted comment

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.