Deep-dive on the Next Gen Platform. Join the Webinar!

Skip Navigation
Show nav
Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
    • .NET
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log inorSign up
Hide categories

Categories

  • Heroku Architecture
    • Compute (Dynos)
      • Dyno Management
      • Dyno Concepts
      • Dyno Behavior
      • Dyno Reference
      • Dyno Troubleshooting
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Developer Tools
    • Command Line
    • Heroku VS Code Extension
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery & Integration (Heroku Flow)
    • Continuous Integration
  • Language Support
    • Node.js
      • Working with Node.js
      • Troubleshooting Node.js Apps
      • Node.js Behavior in Heroku
    • Ruby
      • Rails Support
      • Working with Bundler
      • Working with Ruby
      • Ruby Behavior in Heroku
      • Troubleshooting Ruby Apps
    • Python
      • Working with Python
      • Background Jobs in Python
      • Python Behavior in Heroku
      • Working with Django
    • Java
      • Java Behavior in Heroku
      • Working with Java
      • Working with Maven
      • Working with Spring Boot
      • Troubleshooting Java Apps
    • PHP
      • PHP Behavior in Heroku
      • Working with PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
    • .NET
      • Working with .NET
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
      • Migrating to Heroku Postgres
    • Heroku Key-Value Store
    • Apache Kafka on Heroku
    • Other Data Stores
  • AI
    • Working with AI
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
      • Single Sign-on (SSO)
    • Private Spaces
      • Infrastructure Networking
    • Compliance
  • Heroku Enterprise
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
  • Language Support
  • Java
  • Troubleshooting Java Apps
  • JVM Runtime Metrics

JVM Runtime Metrics

English — 日本語に切り替える

Last updated December 09, 2024

Table of Contents

  • General Information
  • Getting Started
  • Available Metrics
  • Performance implications
  • Using with JRuby
  • Disabling Metrics Collection

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 dynos except for eco dynos.

General Information

For general information on language specific metrics, please refer to the language runtime metrics parent document.

Getting Started

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.

Available Metrics

It may take a few minutes for these metrics to become available after the steps above are completed.

Heap Memory Usage

This chart plots, in megabytes (MB) the overall memory quota and the maximum heap memory usage across all dynos in the currently selected process type. Summary metrics for the selected time interval, including latest, average and maximum memory, are also displayed.

jvmmetrics1

How to use this 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 Java CLI for further diagnosis.

Non-Heap Memory Usage

This chart plots, in megabytes (MB) the overall memory quota (note: the memory quota time series is toggled off in this screenshot), the maximum non-heap memory usage, the maximum buffer pool direct memory usage, and the maximum buffer pool mapped memory usage, across all dynos in the currently selected process type. Summary metrics for the selected time interval, including latest, average and maximum memory, are also displayed.

jvmmetrics2

The buffer pool mapped and direct time series will only show up if you have any memory usage of those types during the selected timeframe.

How to Use This Chart

The non-heap memory usage chart can be used to identify memory leaks or excessive consumption of Metaspace and buffer pools. For more information on debugging these kinds of problems, see the article on Troubleshooting Memory Issues in Java Applications.

Aggregate Time Spent in Garbage Collection

This chart plots the aggregate amount of time that was spent doing garbage collection during each roll up, broken down by Young and Old generations. In the legend, you will see a breakdown of the percentage of time during the roll up was spent running the garbage collector.

jvmmetricsgc

Aggregate Garbage Collections

This chart plots the aggregate number of times that the garbage collector ran during each roll up, broken down by Young and Old generations.

jvmmetricsgc2

How to Use These Charts

The garbage collection charts can be used to tune both the GC and the heap. Like many performance issues, choosing a heap size is a matter of balance. If the heap is too small, the program will spend too much time performance GC. But a very large heap will increase the duration of those pauses. A good rule of thumb is to size the heap so that it is 30% occupied after a full GC, as indicated by the GC chart.

Performance implications

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
  • ~200 additional classes loaded, resulting in < 1MB of additional Metaspace (off-heap) memory
  • 1 additional thread

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"

Keep reading

  • Troubleshooting Java Apps

Feedback

Log in to submit feedback.

Troubleshooting Memory Issues in Java Applications Troubleshooting Memory Issues in Java Applications

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure
  • .NET

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing
  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Github
  • LinkedIn
  • © 2025 Salesforce, Inc. All rights reserved. Various trademarks held by their respective owners. Salesforce Tower, 415 Mission Street, 3rd Floor, San Francisco, CA 94105, United States
  • heroku.com
  • Legal
  • Terms of Service
  • Privacy Information
  • Responsible Disclosure
  • Trust
  • Contact
  • Cookie Preferences
  • Your Privacy Choices