Generalize approach to recover from java memory errors to be useful for all command line programs. Add recovery to bamprep processing, which can also suffer from out of memory problems at scale