Obtaining Heap Dumps when Java Process pid is 1 fails.
When trying to create a heap dump when the Java Process ID is 1 for OpenJDK8 fails with the following error
1: Unable to get pid of LinuxThreads manager thread
See Related issues
- https://github.com/docker-library/openjdk/issues/372
- https://github.com/docker-library/openjdk/issues/76
We have a patch that fixes this issue in Corretto-8.
Reproducer
Run
cat <<EOF > Main.java
public class Main {
public static void main(String[] args) {
while(true) {
}
}
}
EOF
cat <<EOF > Dockerfile
FROM alpine:latest
RUN apk add openjdk8
ADD Main.java ./
RUN /usr/lib/jvm/java-8-openjdk/bin/javac Main.java
ENTRYPOINT java Main
EOF
docker build . -t test-image
docker run test-image
In a separate terminal in run
docker ps # Obtain the container id for the previously executed container
docker exec -it <container_id> /bin/sh
jmap -dump:format=b,file=heap.bin 1
Edited by Clive Verghese