Mark
Mark

Reputation: 29129

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

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?

Upvotes: 8

Views: 3030

Answers (2)

MeplatMasher
MeplatMasher

Reputation: 106

The -XX:OnOutOfMemoryError parameter doesn't work for me with spaces in the command on JRE 7(1.7.0_72). But pointing to a shell script (without spaces) does. Example:

-XX:OnOutOfMemoryError="/path/to/shell/script.sh"

Upvotes: 0

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.

Upvotes: 5

Related Questions