JVM Runtime Metrics
Last updated 25 January 2018
Table of Contents
The JVM Runtime Metrics feature allows you to view heap and non-heap memory, as well as garbage collection activity, for any app that runs inside of the Java Virtual Machine (JVM). This includes (but is not limited to) apps written in Java, Clojure, Gradle, Lein, Maven, Scala, and JRuby,
JVM Runtime Metrics are available for all paid dynos (Hobby and above) and Private Spaces.
For general information on language specific metrics, please refer to the language runtime metrics parent document.
heroku/metrics buildpack is no longer required for JVM Runtime Metrics as of Monday, December 11th, 2017.
Once you have enabled the Enhanced Language Metrics feature (by following these instructions), re-deploy your application using an empty commit.
$ git commit --allow-empty -m "Enable Heroku Metrics" $ git push heroku master
Afterwards, your application should begin exporting memory metrics for the JVM.
It may take a few minutes for these metrics to become available after the steps above are completed.
Heap and Non-heap Memory
Once setup, JVM runtime metrics will add new heap and non-heap memory graphs to the Metrics tab on Heroku dashboard. Summary metrics for the selected time interval, including latest, average and maximum memory, are also displayed for each chart. Heap memory is where dynamically allocated memory resides. If you see heap memory growing unexpectedly, that’s typically an indication of a memory leak. You can use tools like Heroku Exec for further diagnosis.
Garbage Collection Activity
In addition to new memory graphs, JVM runtime metrics will add a garbage collection activity chart. The chart displays the amount of time that was spent doing garbage collection for each time increment. High garbage collection activity typically has a negative impact on response time. It may also suggest that your app needs more memory.
Language runtime metrics collects data from the JVM running on your dyno. The overall impact of JVM metrics collection on application performance is minimal. In our testing we observed the following:
- an estimated 1MB of additional peak heap usage
- ~300 additional classes loaded, resulting in < 1MB of additional Metaspace (off-heap) memory
- 9 additional threads (3 running, 5 parked, 1 waiting)
Using with JRuby
To use this feature with JRuby, you must include the
heroku/jvm buildpack with your app by running:
$ heroku buildpacks:add -i 1 heroku/jvm
Then redeploy your application.
Disabling Metrics Collection
To disable JVM metrics collection, simply toggle off the Enhanced Language Metrics toggle via the Metrics Preferences panel, or using this CLI command:
$ heroku labs:disable "runtime-heroku-metrics" -a "my-app-name"
Removing the Runtime Metrics Buildpack
heroku/metrics buildpack is no longer required for JVM Metrics, so you may want to remove it from your application. This can be done through the CLI or the dashboard
You can remove the buildpack through the Dashboard by going to your app’s Settings page, or by using the command line interface (CLI) and running the following:
$ heroku buildpacks:remove heroku/metrics -a "my-app-name"
Lastly, for your buildpack removal to take effect, you must create a new commit and re-deploy.
$ git commit --allow-empty -m "Remove Runtime Metrics Buildpack" $ git push heroku master