[JAVA] How to get a heapdump from a Docker container

When running a Java application with Docker, a memory leak may occur and the application may crash. Dump the heap used by java at that time so that it can be parsed.

Set the heap dump option in JAVA_OPTS in Dockerfile

ENV JAVA_OPTS="-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/dump.hprof"

Get a heap dump with Docker cp

docker ps -aq | xargs -I{} docker cp {}:/tmp/dump.hprof /tmp/{}_dump.hprof

Parse heap dump

Use MAT or jhat for analysis

memory analyzer (MAT)


Reference URL

Recommended Posts

How to get a heapdump from a Docker container
How to deploy to Heroku from a local docker image
How to make a Java container
How to get inside a container running on AWS Fargate
[Docker] How to access the host from inside the container. http://host.docker.internal:
[IOS] How to get data from DynamoDB
[Docker] Copy files from docker container to host
How to check the logs in the Docker container
How to deploy a container on AWS Lambda
How to develop from VScode in a remote destination environment or a remote destination container environment
Setting to exit from Docker container with VScode
Copy files from docker container to host (docker cp)
How to get Class from Element in Java
How to install Docker
I made a Docker container to run Maven
How to update pre-built files in docker container
How to get SIMD optimization from HotSpot JavaVM
How to start a Docker container with a volume mounted in a batch file
[Spring Boot] How to get properties dynamically from a string contained in a URL
How to get an arbitrary digit from a number of 2 or more digits! !!
How to jump from Eclipse Java to a SQL file
List how to learn from Docker to AKS on AWS
Create a Docker container to convert EPS to PGF source
[Java] How to get a request by HTTP communication
[Java] How to erase a specific character from a character string
How to get started with creating a Rails app
Push Docker images from GitHub Actions to GitHub Container Registry
How to get jdk etc from oracle with cli
Migrating from vargrant to docker
How to leave a comment
How to set Docker nginx
How to migrate from JUnit4 to JUnit5
How to insert a video
How to create a method
[Docker] How to update using a container on Heroku and how to deal with Migrate Error
[Docker] How to see the contents of Volumes. Start a container with root privileges.
Let's write how to make API with SpringBoot + Docker from 0
How to connect a container created later to an existing network
How to create a lightweight container image for Java apps
[iOS] [Objective-C] How to update a widget from an Objective-C app
[IOS] How to get the table name from AWS DynamoDB
How to create a form to select a date from the calendar
[Java] How to convert a character string from String type to byte type
How to store a string from ArrayList to String in Java (Personal)
How to get the longest information from Twitter as of 12/12/2016
How to Burning a Install Disk of Windows from Ubuntu
How to get started with Gatsby (TypeScript) x Netlify x Docker
[Personal notes] How to push a Docker image to GitHub Packages
How to build a Jenkins server with a Docker container on CentOS 7 of VirtualBox and access the Jenkins server from a local PC
[IOS14] How to get Data type image data directly from PHPickerViewController?
[Docker context] ~ How to access docker in remote environment from VScode ~
[jsoup] How to get the full amount of a document
How to use Java HttpClient (Get)
Introduction to Linux Container / Docker (Part 1)
How to push from Tarminal to GitHub
How to get started with slim
How to sign a Minecraft MOD
How to make a JDBC driver
Run React on a Docker container
How to run JavaFX on Docker
How to get parameters in Spark