Update Heaper.java

Add try-catch clause and recover from OutOfMemoryError