better error message when running out of Java CPU or CUDA GPU memory