Some told me that you can run commands when JVM runs out of memory but I am not sure if the below command will work or not as I do expect that this will only kill jira service, and not have time to start it again.
This has to go inside bin/setenv.sh file:
JVM_SUPPORT_RECOMMENDED_ARGS="-XX:OnOutOfMemoryError=\"service jira stop;service jira start\""
Please state if this will work and if not please suggest and alternative that works.
This command works just fine
java '-XX:OnOutOfMemoryError=nohup bash -c "service jira stop;service jira stop" &' test
Still, the trick of putting it inside the is more complex than it may seem, check http://stackoverflow.com/questions/11687292/how-to-do-a-proper-double-or-triple-bash-quote-escape