3 ms·
When you say concurrent, do you mean "works with threads" or "doesn't pause"?
by juliangregorian 11y ago
When you say concurrent, do you mean "works with threads" or "doesn't pause"?
- kazinator 11y agoIt's both. If it doesn't work with threads, there is no concurrency. If the threads have to stop, it's still concurrency in the sense that threads are stopped in arbitrary places (just like an interrupt can stop a task at any point in its execution and dispatch another task or whatever). But the garbage collector isn't running concurrently with the threads. I.e. I think the term "concurrent garbage collector" is understood to be in contrast with "stop-the-world garbage collector" not with "synchronous garbage collector as a library function in a single-threaded virtual machine".
- juliangregorian 11y agoForgive my ignorance, but are there any extant examples of garbage collectors (real GC, not reference counting) that don't stop the world?
- nostrademons 11y agoSo when you say "real GC, not reference counting", you have to understand that tracing GC and reference counting are duals, and every concurrent collector is going to be some hybrid of the two [1]. But there are a number of algorithms that most people would probably consider "real GC" that don't stop the world. Modern Java GCs use the train algorithm [2], which bounds pause times to some arbitrarily-sized constant. Erlang per-process heaps [3] also give good soft-real-time characteristics. It is theoretically possible to run the whole GC in a background thread (eg. while a GUI is idle). Both the JVM and the CLR have options for this [4][5], but they're only useful for workloads with large pause times (eg. GUI apps, lightly-loaded servers) and so aren't enabled by default. [1] http://researcher.watson.ibm.com/researcher/files/us-bacon/Bacon04Unified.pdf http://researcher.watson.ibm.com/researcher/files/us-bacon/B... [2] http://www.ssw.uni-linz.ac.at/General/Staff/TW/Wuerthinger05Train.pdf http://www.ssw.uni-linz.ac.at/General/Staff/TW/Wuerthinger05... [3] http://prog21.dadgum.com/16.html http://prog21.dadgum.com/16.html [4] http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html#cms http://www.oracle.com/technetwork/java/javase/gc-tuning-6-14... [5] https://msdn.microsoft.com/en-us/library/ee787088(v=vs.110).aspx#concurrent_garbage_collection https://msdn.microsoft.com/en-us/library/ee787088(v=vs.110)....