What exactly happens behind the scenes when calling System.gc ()?

Calling System.gc () requests garbage collection and is not guaranteed. I’m not interested in the part about this, which is not guaranteed: can someone explain the exact process that occurs when you make this call?

+1
source share
3 answers

There is no guarantee that garbage collection will take place, because there is no guarantee that the JVM supports garbage collection (I don’t think it is mentioned in JLS at all, of course, not in index ).

However, I think this belief that “this is not guaranteed” is a little inappropriate. From Sun API docs :

, Java , .

, , , , , JVM GC, . , JVM , , , - , , .

, . JVM , .

+2

JVM , . , , .

Java " , , ". 1) 2) , .

Sun JVM , , , , .

Suns , gc java 5, , :

http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html

+1

JVM.

- , .. .

JVM System.gc() , . IBM Java: , , GC, , , GC.

Sun GC- Java SE 6 HotSpot [tm] .

+1

All Articles