Reputation: 29129
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
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
Reputation: 51
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