Measuring time spent on GC in JVM

后端 未结 7 1130
天命终不由人
天命终不由人 2020-12-03 01:47

Suppose I am testing a Java server application. I know how much time it takes to finish the test. Now I\'d like to know how much was spent on GC during that test. How can I

7条回答
  •  生来不讨喜
    2020-12-03 02:24

    This performance metric is recorded by the JVM, and made accessible through JMX. For interactive monitoring, connect to the running JVM with JConsole, and in the "VM Summary" Tab it will say something like:

    Garbage collector: Name = 'Copy', Collections = 26, Total time spent = 0.183 seconds Garbage collector: Name = 'MarkSweepCompact', Collections = 2, Total time spent = 0.168 seconds

    You can also query JMX programatically.

提交回复
热议问题