---
title: "How to monitor the JVM heap size"
description: "Monitoring JVM heap size involves using the JMX Plugin to retrieve MBean attribute values. Configuration requires setting the serviceUrlRmi variable with the correct JMX service URL details."
url: "https://docs.itrsgroup.com/docs/faq/geneos/115004022345-geneos-how-to-monitor-the-jvm-heap-size/index.html"
---
The JMX Plugin can be configured to connect to the monitored JVM application, look up specific Mbeans and retrieve values of their attributes (such as heap size).

Below is a sample JMX template that captures the heap memory usage.  In the JMX sampler, the *serviceUrlRmi* variable should point to the serviceURL which contains the hostname/IP, port and JMX details. The format would look like *service:jmx:rmi:///jndi/rmi://<jmxhost>:<jmxport>/jmxrmi*.

```
<sampler name="JMX HeapMemory Demo">  <plugin>  <jmx-server>  <connection>  <generic>  <serviceURL>  <var ref="serviceUrlRmi"/>  </serviceURL>  </generic>  </connection>  <aliases>  <alias>  <name>$1</name>  <value>  <data>java.lang:type=Memory,*</data>  </value>  </alias>  </aliases>  <columns>  <column>  <label>Name</label>  <rowTemplate>  <data>HeapMemory</data>  </rowTemplate>  </column>  <column>  <label>Init</label>  <rowTemplate>  <data>$1.HeapMemoryUsage.init</data>  </rowTemplate>  </column>  <column>  <label>Max</label>  <rowTemplate>  <data>$1.HeapMemoryUsage.max</data>  </rowTemplate>  </column>  <column>  <label>Used</label>  <rowTemplate>  <data>$1.HeapMemoryUsage.used</data>  </rowTemplate>  </column>  <column>  <label>Committed</label>  <rowTemplate>  <data>$1.HeapMemoryUsage.committed</data>  </rowTemplate>  </column>  </columns>  <idAttributes/>  </jmx-server>  </plugin> </sampler>
```

Below is the dataview of the XML configuration above:  ![Screenshot](https://docscdn.itrsgroup.com/faq/images/geneos/115004022345-360003948717-mceclip0.png)

Please see the [JMX Plugin documentation](https://docs.itrsgroup.com/docs/geneos/current/collection/jmx-server/index.html) for more details.


