I am getting lang.OutOfMemoryError: Java heap space


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


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.. :-)

By : ggcodes

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.".

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:


By : uldall

This video can help you solving your question :)
By: admin