Core Java

Garbage Collection CPU Statistics

When a Garbage Collection event runs, it spends a predominant amount of its time in the Java application layer. It also spends a certain portion of its time in the Operating System/Kernel layer. 

‘User’ Time:

Amount of time Garbage Collector spends in the Java application layer is reported as ‘User’ time in the GCeasy report. Here are the reasons for the ‘User’ time:

a. Garbage collector has to mark all the objects & identify the ones with active references.

b. It has to evict unreferenced objects in the memory.

‘Sys’ Time:

Amount of time Garbage Collector spends in the Operating system/kernel layer is reported as ‘Sys’ time in the GCeasy report. Here are the reasons for the ‘Sys’ time:

a. When there is demand for the memory, the application will ask for additional memory from the Operating System. To allocate that memory to JVM, it will take some time. Once memory pressure goes away, JVM will give back the memory to the operating system. This deallocation will also take time. 

b. JVM sometimes may request large pages (like in the magnitude of 2mb size/page). If the operating system cannot find contiguous free space to allocate 2mb pages, then it will stop all the processes that are running and start moving around the data to find contiguous free space. This will take time.

c. JVM creates and writes statistics about safepoints and garbage collection events in the /tmp/hsperfdata_(username) file. This file gets updated when GC events run. Occasionally linux kernel threads block the GC threads from updating this file when there is heavy disk I/O. Thus very heavy disk I/O activity can increase ‘sys’ time. 

d. Due to lack of memory, Operating system might swap your application in & out of memory. This swapping time will be reported as ‘sys’ time.

e. Sometimes there could be certain problems in the Operating system (such as System faults, misaligned memory references, floating point exceptions) – then in such circumstances Garbage collectors will have to spend more time on the OS/Kernel layer.

‘CPU’ Time:

CPU time is the total amount of time an application spends in garbage collection. It’s basically the sum of ‘User’ time and ‘Sys’ time.

Published on Java Code Geeks with permission by Ram Lakshmanan, partner at our JCG program. See the original article here: Garbage Collection CPU Statistics

Opinions expressed by Java Code Geeks contributors are their own.

Ram Lakshmanan

Ram Lakshmanan developed world's finest DevOps tools:,, Every single day, millions & millions of people in North America—bank, travel, and commerce—use the applications that Ram Lakshmanan has architected. Ram is an acclaimed speaker in major conferences on scalability, availability, and performance topics. Recently, he has founded a startup, which specializes in troubleshooting performance problems.
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Back to top button