Catch OutOfMemory error in the JobHandlers
Wraps JobHandler.run() in a try catch block to manage:
- the OutOfMemory (Java heap space) errors.
- the submonitor creation and stop
- the timing print messages
JobHandler instance must implements the _run() method.
In case of error, show a message to help the user setting the jvm available memory.
Add a JobHandler.onJobFailure() method to manage errors when the job is stopped.
all JobHandler instances must be fixed to throw the exceptions to the parent class
Validation test
- Create a new macro with the following code
def a = \[\] for (int i = 0 ; i \< 1000000 ; i++) a \<\< new String\[100000000\]; println "done ?"
- run the macro
- the console displays the error message
Compilation de AAAAMacro.groovy...
Exécution du script Groovy AAAAMacro.groovy…
** Erreur lors de l'exécution du script : java.lang.OutOfMemoryError: Java heap space
Stacktrace:
[1] org.txm.rcp.handlers.scripts.ExecuteGroovyScript$1._run ExecuteGroovyScript.java, 284
[2] org.txm.rcp.utils.JobHandler. run JobHandler.java, 103
The operation could not end correctly because of a memory error: java.lang.OutOfMemoryError: Java heap space
You can raise the available memory in the TXM > Advance preference page.