JVM - Memory (The Heap)


The JVM memory consists of the following segments:

  • Heap Memory, which is the storage for Java objects
  • Non-Heap Memory, which is used by Java to store loaded classes and other meta-data
  • JVM code itself, JVM internal structures, loaded profiler agent code and data, etc.



The environment variable JVM_ARGS is used to override JVM settings.

For example:

set JVM_ARGS="-Xms1024m -Xmx1024m -Dpropname=propvalue" 

Property Name


The heap memory is used to store Java Object.

The heap size may be configured with the following VM options when starting the JVM

-Xms<size> - to set the minimal/starting Java heap size
-Xmx<size> - to set the maximum Java heap size

By default, the maximum heap size is 64 Mb. If the application asks more than the maximum the JVM will throw the following exception: java.lang.OutOfMemoryError : Java Heap space.

The heap is managed by the garbage collector policy.

Permanent generation

-XX:MaxPermSize (Maximum size of the permanent generation)




java -Xms256m -Xmx2048m -XX:MaxPermSize=512m -jar myJar.jar


-Xms256m -Xmx2048m -XX:MaxPermSize=512m
-Xms128m -Xmx1024m -XX:MaxPermSize=256m
-Xms64m  -Xmx512m  -XX:MaxPermSize=128m


Memory Analyzer (MAT)

Memory Analyzer (MAT)

The Eclipse Memory Analyzer is a fast and feature-rich Java heap analyzer that helps you find memory leaks and reduce memory consumption.

Use the Memory Analyzer to analyze productive heap dumps with hundreds of millions of objects, quickly calculate the retained sizes of objects, see who is preventing the Garbage Collector from collecting objects, run a report to automatically extract leak suspects.

Query heap dump via SQL

Powered by ComboStrap