HEAP Memory

heap-usage

 

  • Login to your Linux/Unix Server
  • Enter the below command to get the JAVA PID running on the server.

                          ps –ef|grep –i java

From the output take the application JAVA PID.

  • Using jstat command with gc option to find out the JVM Heap Memory Usage.

<JAVA_HOME>/bin/jstat –gc <JAVA PID>

heap-jstat

S0C – CURRENT SURVIVOR SPACE 0 CAPACITY (KB).
S1C  –  CURRENT SURVIVOR SPACE 1 CAPACITY (KB).
S0U – SURVIVOR SPACE 0 UTILIZATION (KB).
S1U  – SURVIVOR SPACE 1 UTILIZATION (KB).
EC    – CURRENT EDEN SPACE CAPACITY (KB).
EU    – EDEN SPACE UTILIZATION (KB).
OC    – CURRENT OLD SPACE CAPACITY (KB).
OU    – OLD SPACE UTILIZATION (KB).
PC     – CURRENT PERMANENT SPACE CAPACITY (KB).
PU     – PERMANENT SPACE UTILIZATION (KB).
YGC   – NUMBER OF YOUNG GENERATION GC EVENTS.
YGCT – YOUNG GENERATION GARBAGE COLLECTION TIME.
FGC   – NUMBER OF FULL GC EVENTS.
FGCT – FULL GARBAGE COLLECTION TIME.
GCT   – TOTAL GARBAGE COLLECTION TIME.

When you add all the ‘utilizations’ i.e OU + EU + S0U + S1U  you get the total Heap utilization.

Use Below command if you lazy enough to calculate the above and to get Heap utilisation in one command.

heap-total

Heap Utilization using jmap 

  • Enter the below command to get the JAVA PID running on the server.

                          ps –ef|grep –i java

From the output take the application JAVA PID.

  • Using jstat command with gc option to find out the JVM Heap Memory Usage.

<JAVA_HOME>/bin/jmap –heap <JAVA PID>

heap-jmap

jmap-heap-usage

 

Calculate the Heap Utilisation  by adding the used value of

New Generation (Eden + 1 Survivor Space):
+
concurrent mark-sweep generation:

 

There are other tools like visualvm, APM tools to get the heap memory usage. If this article found useful please comment and let me know how can i improve.

Advertisements