-1

I have one execute method in try block.if this method thorows any exception catch block will handle that exception.I called execute method in Test classs in try bock. my problem Test catch block handle the exception java.lang.OutOfMemoryError: Java heap space

ggcodes
  • 2,859
  • 6
  • 21
  • 34

4 Answers4

1

Given the OutOfMemoryError is not the result of a programming error, and your program really need this amount of memory then you could try and increase the heap space given to the application. See:

http://viralpatel.net/blogs/jvm-java-increase-heap-size-setting-heap-size-jvm-heap/

uldall
  • 2,458
  • 1
  • 17
  • 31
1

Even if it could be caught with a catch, you shouldnt. OutOfMemoryError tells you that either your application cannot run in the conditions or your application is not programmed properly.

user2138983
  • 1,313
  • 9
  • 15
0

Because OutOfMemoryError is an Error, not an Exception. Since OutOfMemoryError isn't a subclass of Exception, the catch (Exception e) doesn't apply.

Follow this link it may answer your question..

“java.lang.OutOfMemoryError: Java heap space”

accept if it helps.. :-)

Community
  • 1
  • 1
ggcodes
  • 2,859
  • 6
  • 21
  • 34
0

The cause might be an infinitely recursing function, or a unending loop with an evergrowing list. This can be trivial: intending in paint to call super.paint but forgetting "super.".

Joop Eggen
  • 107,315
  • 7
  • 83
  • 138