Reputation: 4347
I have not been able to find the type of GC that System.gc()
recommends the JVM to do. Here, it is said that "the System.gc()
method ... forces major collections", but this post implies a full gc is requested.
Could anyone clarify or point to documentation that spells this out? In other words, is it a major or full gc that is requested?
Upvotes: 3
Views: 3514
Reputation: 43052
That depends on the JVM you're using.
Assuming you're using hotspot the behavior varies based on flags passed to it. By default it triggers a full stop-the-world GC, which will show up as the gc cause [Full GC (System.gc)]
in the logs. With DisableExplicitGC
it won't invoke any GC at all. If G1 or CMS are used then ExplicitGCInvokesConcurrent
will change that behavior to initiate a concurrent old gen collection instead.
The major and minor terminology is not very useful anymore since GC cycles have become more nuanced.
If in doubt, enable GC logging and see for yourself.
Upvotes: 3