I didn't want to use BinaryDelta.apply(data,cmds) here because I didn't want an OOM caused by a failed allocation for an IllegalArgumentException inside of BinaryDelta.apply() to be trapped and treated the same as an OOM caused by trying to allocate a byte array that is too large for our current heap.

Catching OOM is usually considered to be VERY BAD.  If your heap is really out of memory, your whole VM is about to fall over for most Java applications.  I know that's true for Eclipse.  :-)

Thus I've been very careful to only trap OOM on a very small number of byte array allocations, where the size of the array might be larger than the maximum heap, and that will trigger an OOM, but its not really an OutOfMemoryError, because there is still plenty of heap to go around.  E.g. consider the case of streamFileThreshold being set to 2047m, an object of 640m in size, and a max heap of 256m.  Even if I have 200m free in the heap, I cannot allocate that 640m object as a byte array, and the resulting OOM from that alloc isn't really an OOM.  The heap is still fine.

But an OOM when we are about to throw IllegalArgumentException, well, that's really bad.  If we cannot perform the allocation for an exception that we want to throw up the stack, we're toast.  Our heap is already out of space and there's no way we're going to be able to recover.  We shouldn't be trapping that exception.