I know about the -XX:+HeapDumpOnOutOfMemoryError JVM parameter. I also know about -XX:OnOutOfMemoryError=\"cmd args;cmd args\" and that kill -3 will
kill -3
java -XX:+HeapDumpOnOutOfMemoryError -XX:OnOutOfMemoryError="kill -9 %p" TestApp
JVM will dump heap first, and then execute OnOutOfMemoryError commands (proof).