Hacker News new | ask | show | jobs
by wonnage 3027 days ago
The purpose of separating into young and old generation is that it's easier to find dead objects in the young generation (as you said, average object lives for a short period of time). You only have to scan this subset for a minor GC. It doesn't really matter how many long-lived objects you have as long as you can avoid needing to do a major GC.
1 comments

Don't you still need to scan the old generation during minor GC, in case a field in one of the older objects was modified to point to an object in the young generation? Or are there optimizations you can use to quickly and efficiently find references from the older generation to the younger?
> in case a field in one of the older objects was modified to point to an object in the young generation?

This is typically handled by https://en.wikipedia.org/wiki/Write_barrier#In_Garbage_colle...