This Julia process exited with code 9. Press any key to close the terminal

I’m running code that has two potential problem areas: a large dataframe with images, and an analysis which may create arrays that aren’t gc’d. When I run the code, either in VS Code or the REPL i get the unhelpful message that the process was killed. No helpful “out of memory” errors or other errors with a stack trace that would help me figure out what’s going on. What do I do to diagnose what’s going on when I don’t have much to point to? Are there diagnostic calls I can put in my code to help out? Should I be wrapping my loops in a try catch block? Forgive me, but I’m spitballing here…

Thanks,
–Markos

It’s very likely your Julia process got killed (with kill -s 9 $pid, which is where that exit code comes from) because your system was short on memory. Your system’s kernel logs should tell you exactly what happened (check with e.g. sudo dmesg -T and look out for Out of memory: Killed process ...).

There’s nothing you can do in your Julia code to prevent that from happening except for allocating less memory. It’s hard to say what exactly needs to be changed from your description (except “make sure every temporary allocation is GC’able”), but maybe give the allocation profiler a go: