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
-
Post code of the method you call – bsiamionau Mar 06 '13 at 08:09
-
1Post the code that's giving you errors. OutOfMemoryErrors are not enough information. – Warwick Masson Mar 06 '13 at 08:09
-
1Some code would be helpful. Not everyone has fortune telling skills ;). But maybe an additional info: Errors are that type of thrown stuff, which are not meant to be handleable by programmers. – Joshua Mar 06 '13 at 08:10
4 Answers
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/

- 2,458
- 1
- 17
- 31
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.

- 1,313
- 9
- 15
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.. :-)
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.".

- 107,315
- 7
- 83
- 138