Re:Rust: Dropping heavy things in another thread can make yo...
by tsimionescu on Sunday May 31, 2020 @07:37AM
(#23368894)
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.
Re:Rust: Dropping heavy things in another thread can make yo...
by pron on Sunday May 31, 2020 @08:39AM
(#23369182)
Not 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.
Yes, but in practice tracing in a tracing GC is done concurrently and with the help of GC barriers that don't require synchronization and so are generally cheaper than the common mechanisms for reference-counting GC.
> and to invoke finalizers
As others have said, finalizers are very uncommon and, in fact, have been deprecated in Java.