ericire,
Yeah, ScriptMaster just handles Groovy code and passes it. I think the behavior you're seeing is when the HeapSpace error occurs, Groovy bubbles it down to the "new File" and because it failed due to loss of memory, it views the "new File" as null and throws a FileNotFound. Curious behavior.
You may be able to do:
try {
//main code here
} catch (OutOfMemoryError e) {
//handling code here
}