Simplify acquisition and release of java memory resources.