Использовать catch OutOfMemoryError not Exception!
try { // your code } catch (OutOfMemoryError e) { }