Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default Garbage collector for a jvm [duplicate]

Tags:

java

Possible Duplicate:
find which type of garbage collector is running

Is there a way to tell what garbage collector is being used in a jvm by default?

like image 409
user640121 Avatar asked Mar 03 '11 00:03

user640121


2 Answers

This will print out a list of all of the Garbage Collectors currently loaded in your JVM.

import java.lang.management.*;
import java.util.List;

public class x {
    public static void main(String args[]) {
        List<GarbageCollectorMXBean> l = ManagementFactory.getGarbageCollectorMXBeans();
        for(GarbageCollectorMXBean b : l) {
            System.out.println(b.getName());
        }
    }
}
like image 131
Will Hartung Avatar answered Oct 11 '22 16:10

Will Hartung


Is JConsole what you're after?

Excerpt:

Garbage collector information: Information on GC, including the garbage collector names, number of collections performed, and total time spent performing GC.

like image 43
Michael Berry Avatar answered Oct 11 '22 16:10

Michael Berry