On Linux, when used, the -XX+HeapDumpOnOutOfMemoryErrorcreated hprof file belongs to the user in which the Java process runs and has 600 permissions.
-XX+HeapDumpOnOutOfMemoryError
I understand that these permissions are best secure, but can I override them?
You can start the JVM with
java -XX:+HeapDumpOnOutOfMemoryError -XX:OnOutOfMemoryError="chmod g+r java_pid*.hprof" {mainclass} {args}
The command runs after heap dump. This will allow access to the group to view all heap dump files in the current directory, for example.
The parameter -XX:OnOutOfMemoryErrordoes not work for me with spaces in the JRE 7 command (1.7.0_72). But point to shell script (no spaces). Example:
-XX:OnOutOfMemoryError
-XX: OnOutOfMemoryError = "//// script.sh"