Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you override the file permissions for the heap dump produced by -XX+HeapDumpOnOutOfMemoryError?

Tags:

java

jvm

On Linux when using -XX+HeapDumpOnOutOfMemoryError the hprof file produced is owned by the user under which the java process is running and has permissions of 600.

I understand that these permissions are best security wise but is it possible to override them?

like image 269
Mark Avatar asked Sep 18 '12 20:09

Mark


People also ask

How do I get rid of heap dump on memory error?

In order to capture a heap dump automatically, we need to add the HeapDumpOnOutOfMemoryError command-line option that generates a heap dump when a java. lang. OutOfMemoryError is thrown.

How do I access heap dump?

Right-click on one of the Java process. Click on the 'Heap Dump' option on the drop-down menu. Heap dump will be generated. File path where heap dump is generated will be specified in the Summary Tab > Basic Info > File section.


1 Answers

You can start the JVM with

java -XX:+HeapDumpOnOutOfMemoryError -XX:OnOutOfMemoryError="chmod g+r java_pid*.hprof" {mainclass} {args}

The command runs after the heap dump is created. This will allow group read access to all heap dump files in the current directory for example.

like image 57
stribika's Morgan Stanley acc Avatar answered Oct 19 '22 23:10

stribika's Morgan Stanley acc