How to set the directory where JVM stores MDMP files

Reto Merz reto.merz at abacus.ch
Wed Oct 2 15:03:55 UTC 2019


> It looks to me that  core dumps (Linux) and MDMP files (Windows) are
> written to the current directory and there
> is no way to override this without building a custom JDK.
> 
> I only looked at the JDK14 sources (os_linux.cpp and os_windows.cpp) but I
> suspect the same is true on JDK11.

Thank you for your help and the info.

> Is there an option of having your program change the current directory?

Yes we are already in contact with our hoster to gain access for the work dir.

Thanks
Reto



> -----Ursprüngliche Nachricht-----
> Von: Bob Vandette [mailto:bob.vandette at oracle.com]
> Gesendet: Dienstag, 1. Oktober 2019 15:15
> An: Reto Merz
> Cc: jdk-dev at openjdk.java.net
> Betreff: Re: How to set the directory where JVM stores MDMP files
> 
> It looks to me that  core dumps (Linux) and MDMP files (Windows) are
> written to the current directory and there
> is no way to override this without building a custom JDK.
> 
> I only looked at the JDK14 sources (os_linux.cpp and os_windows.cpp) but I
> suspect the same is true on JDK11.
> 
> Is there an option of having your program change the current directory?
> 
> Bob.
> 
> 
> > On Oct 1, 2019, at 8:13 AM, Reto Merz <reto.merz at abacus.ch> wrote:
> >
> > Hello,
> >
> > (Not sure whether this is the correct place to ask this, so please forgive me
> if not.)
> >
> > A) I want to change the location where the MDMP-file is created. I set the
> following JVM args:
> >        -XX:HeapDumpPath=C:/the_dumps
> >        -XX:ErrorFile=C:/the_dumps/hs_err_pid%p.log
> >
> > According to a old stackoverflow answer [1] this should work.
> > But the MDMP-file is still created in the working directory. Is it possible to
> change it?
> > Below you will find the code to cause a crash [2].
> >
> > Tested with java -version
> >    openjdk version "11.0.4" 2019-07-16
> >    OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.4+11)
> >    OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.4+11, mixed mode)
> >
> > B) If there is a way to change the MDMP-file location, does the same apply
> for linux?
> > As far as I know linux will create a CORE file (instead of a MDMP).
> >
> > Thanks
> > Reto Merz
> >
> > [1] https://stackoverflow.com/questions/33666412/how-to-set-the-
> directory-where-jvm-stores-mdmp-files
> > [2] Code to crash JVM:
> >
> > import java.lang.reflect.*;
> > public class Main {
> >    public static void main(String[] args) throws Exception {
> >        Class<?> clazz = Class.forName("sun.misc.Unsafe");
> >        Field field = clazz.getDeclaredField("theUnsafe");
> >        field.setAccessible(true);
> >        Object unsafe = field.get(null);
> >        Method putAddress = clazz.getDeclaredMethod("putAddress",
> long.class, long.class);
> >        putAddress.invoke(unsafe, 0L, 0L);
> >    }
> > }
> >



More information about the jdk-dev mailing list