How to get jvm heap dumps if the working directory is read only?

603 Views Asked by At

In my kubernetes application, I am running a java application from a readOnly root directory (ReadOnly root is a must). I do have a mount (folder) that is writable, however when I run:

jmap -dump:live,format=b,file=/dumps/temp/dump.hprof 1

I get the error:

Exception in thread "main" java.io.IOException: Read-only file system
    at java.base/java.io.UnixFileSystem.createFileExclusively(Native Method)
    at java.base/java.io.File.createNewFile(File.java:1035)
    at jdk.attach/sun.tools.attach.VirtualMachineImpl.createAttachFile(VirtualMachineImpl.java:298)
    at jdk.attach/sun.tools.attach.VirtualMachineImpl.<init>(VirtualMachineImpl.java:76)
    at jdk.attach/sun.tools.attach.AttachProviderImpl.attachVirtualMachine(AttachProviderImpl.java:58)
    at jdk.attach/com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:207)
    at jdk.jcmd/sun.tools.jmap.JMap.executeCommandForPid(JMap.java:128)
    at jdk.jcmd/sun.tools.jmap.JMap.dump(JMap.java:208)
    at jdk.jcmd/sun.tools.jmap.JMap.main(JMap.java:114)

I have run the java application with the following options: java -XX:MaxRAMPercentage=90.0 -XX:InitialRAMPercentage=15.0 Dlogback.configurationFile="${CUSTOM_LOGBACK_FILE:-/opt/custom-logback.xml}" -DconfigFile="${SETTINGS_FILE}" -jar "/${ARTIFACT}.jar

0

There are 0 best solutions below