|
There are several variants of the algorithms discussed in the previous sections. For example, the mark-and sweep has two variants compacting and copying mark-and sweep. We won’t be discussing all the algorithms, but that will give you a hint why you cannot be sure about algorithm implemented in a given JVM. Moreover the JVM specification does not mandate any particular implementation for garbage collection. Therefore JVM implementers can implement any algorithm suitable for their own requirement. Usually algorithms that give a fair balance between responsiveness (how quickly garbage-collection thread finishes its job) and speed of memory recovery are adopted. Responsiveness is especially important in time-critical real time systems whereas recovering memory is important for memory intensive applications.