Methods to prevent JVM heap overload

Can anyone suggest a method in which a multi-threaded ram intensive process (batch image processing) be handled to prevent heap error? Is it possible to queue threads if the JVM is coming close to max?
(I have already adjusted the JVM setting beyond the default 512)

Hi Matthew. First question: What are your min/max heap settings at present? In cases like this, an easy “fix” is to make sure the heap doesn’t grow dynamically under load, which is really expensive, and can be the point of no return if a big/blocking process fires off near a full garbage collection. Often times, you can avoid further tuning if you just remove runtime heap allocation from the equation, which you do by setting the min/max to the same number (which should be the max amount of RAM the system can provide to Java). You may already have done that, but, it’s an easy first check. Let us know, and if this is already done we can see what other tweaks we can recommend.