Reputation: 3367
As I read in the Sun Memory management white paper:
When stop-the-world garbage collection is performed, execution of the application is completely
suspended during the collection
So if a request happens while the garbage collector is running then how is it handled by the application? If the garbage collector takes too long will the application throw an exception? I have not come across such an issue but wanted to know is this possible and what exception gets thrown?
Upvotes: 3
Views: 138
Reputation: 979
All (almost) Java garbage collectors has some sort of a Stop-the-world phase where all the Java threads are suspended waiting for a exclusive system operations to complete. This state is sometimes referred to as a safepoint.
The modern garbage collectors are concurrently running together with the applications threads, which means that the garbage collector perform its work at the same time as the application. During the garbage collector process there are phases where exclusive access memory is needed, the application threads goes into this safepoint state.
An exception is thrown if the garbage collector cannot recover enough memory to meet the application´s allocation demands.
One alternative to get rid of the stop-the-world garbage collections is to go for the Zing JVM with the C4 collector from Azul systems. The implementation has a low pause approach with no stop-the-world collections at all. Instead it is using a concurrent compacting approach with no stop-the-world phase.
Upvotes: 1
Reputation: 9954
This garbage collector is not in use anymore and replaced by better garbage collectors.
The stop-the-world
garbage collector really stopped the complete application (all threads) and cleaned up the heap.
When the garbage collector would take too long (which almost never happens) then an Error
would be thrown.
Incomming traffic on network sockets is buffered for the time the collector runs.
Upvotes: 0