jvmmon
or jcmd
. Which tool and command to use depends on the JVM vendor as well as the Java buildpack which is used on SAP BTP Cloud Foundry. To make it as simple as possible to create heap dumps and thread dumps on demand, we've created the cf java
plugin plugin.cf java
plugin is installed as an addition to the Cloud Foundry Command Line Interface (CF CLI), which is used to manage applications on SAP BTP Cloud Foundry.cf java
plugin via the command line:$ cf add-plugin-repo CF-Community http://plugins.cloudfoundry.org
$ cf install-plugin -r CF-Community "java"
cf java
plugin. To view all commands and options supported by the plugin, you can run cf java --help
:$ cf java --help
NAME:
java - Obtain a heap-dump or thread-dump from a running, SSH-enabled Java application.
USAGE:
cf java [heap-dump|thread-dump] APP_NAME
OPTIONS:
--app-instance-index -i [index], select to which instance of the app to connect
--container-dir -cd, the directory path in the container that the heap dump file will be saved to
--dry-run -n, just output to command line what would be executed
--keep -k, keep the heap dump in the container; by default the heap dump will be deleted from the container's filesystem after been downloaded
--local-dir -ld, the local directory path that the dump file will be saved to
cf java
plugin uses an SSH tunnel to connect to a selected application APP_NAME
and instance --app-instance-index
, to trigger a heap dump or thread dump with the JVM specific tools and commands. That said, you need to ensure that your application has the necessary JDK tools installed and SSH access to your application is enabled. By default, SSH access is disabled:$ cf ssh-enabled APP_NAME
ssh is disabled for app
APP_NAME
via the following command and a restart of your application:$ cf enable-ssh APP_NAME
$ cf restart APP_NAME
-Xmx
) configured for the JVM. Therefore, it's not unusual for a heap dump to exceed 1 GB of the available disk space. You can request more disk space via the following property in your manifest file (with a maximum total disk space of 4 GB):---
...
disk_quota: 4G
cf push
. If you don't have the manifest file at hand, you can also use the following command to increase the disk quota:$ cf scale APP_NAME -k 4G
cf java
plugin and transfer it to your local computer:$ cf java heap-dump APP_NAME --local-dir FOLDER
spring-music
and save it into the current folder on your local computer, you can run:$ cf java heap-dump spring-music --local-dir .
Successfully created heap dump in application container at: /var/vcap/data/fcb80119-7117-4682-8285-d7d4740cdf66/java_pid12_5.hprof
Heap dump filed saved to: ./spring-music-heapdump-231be9d8-d3a5-403f-aa44-14637c4510d3.hprof
Heap dump filed deleted in app container
thread-dump
command:$ cf java thread-dump APP_NAME > thread.dump
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
10 | |
9 | |
9 | |
8 | |
8 | |
6 | |
5 | |
5 | |
5 |