3 ms·
No, they are actually fundamentally wrong. GCs never scan garbage - they only scan objects that are referenced from a GC root. Note that the problem appears in
by tsimionescu 6y ago
No, they are actually fundamentally wrong. GCs never scan garbage - they only scan objects that are referenced from a GC root.
Note that the problem appears in a different place: if your large structure is actually not garbage, then every GC pass will have to scan it to see what other objects it is keeping alive.
- pron 6y agoNot every GC pass. Some modern GCs (like OpenJDK's default GC, G1) track mutation and maintain "remembered sets." They only need to scan objects that have changed since the last scan (they're actually even more efficient than that, but this is a simplification). In addition, when this scanning is required, it is performed concurrently to the application, so the technique of moving the work to a separate thread is done automatically.