How can I see which garbage collector java is usin

2019-01-18 11:15发布

The Java Virtual Machine supports several garbage collection strategies.

This article explains them.

Now I am wondering which (automatically selected) strategy my application is using, is there any way to let the JVM(version 1.6) print this information?

Edit: The JVM detects if it is in client or server mode. So the question really is how can I see which has been detected?

7条回答
别忘想泡老子
2楼-- · 2019-01-18 11:53

Looks like, we have more convenient way to define the version of GC at runtime. Always use tools, my suggestion. To define GC version we need two tools that come with JVM (placed in your jdk/bin directory):

  1. VisualVM - start it and try to profile some process (for example you can profile VisualVM itself). Your profile will show you a PID of process (see the green rectangles at a screenshot).
  2. jMap - start this tool with -heap <PID> options and find a string dedicated to a Garbage Collector type (see a pink line at a screenshot)

enter image description here

查看更多
登录 后发表回答