private static boolean isOutOfMemory(Throwable t){
  boolean isOutOfMemory=false;
  while (!isOutOfMemory && t != null) {
    if (t instanceof OutOfMemoryError) {
      isOutOfMemory=true;
    }
 else     if (t instanceof IOException) {
      final String msg=t.toString();
      if (msg != null) {
        isOutOfMemory=msg.contains("Not enough space");
      }
    }
    t=t.getCause();
  }
  return isOutOfMemory;
}

private static boolean isOutOfMemory ( Throwable t ) { boolean isOutOfMemory = false ; while ( ! isOutOfMemory && t != null ) { if ( t instanceof OutOfMemoryError ) { isOutOfMemory = true ; } else if ( t instanceof IOException ) { final String msg = t . toString ( ) ; if ( msg != null ) { isOutOfMemory = msg . contains ( "Not enough space" ) ; } } t = t . getCause ( ) ; } return isOutOfMemory ; }
tells whether this throwable has been generated for an out of memory error or not .
