Enter your E-mail Address below for Free E-mail Alerts right Into your Inbox: -

Wednesday

How to avoid OutOfMemoryError in java

How to avoid OutOfMemoryError in java

java.lang.OutOfMemoryError is the one of the error which is not a Exception and it comes under the list of Error in java.

What is OutOfMemoryError?
OutOfMemoryError is  common when out of memory in heap. It normally comes when a object is tried to allocate a space if it ran out of heap space OutOfMemoryError Error occurs.

Types of OutOfMemoryError:
  1. OutOfMemoryError:- java heap space
  2. OutOfMemoryError:- PermGen space
Size is 64 Mb and used normally in stringpool is OutOfMemoryError PermGen space

How To solve or avoid OutOfMemoryError java heap space:
  1. Normal way to solve this one is JVM options "-Xmx512M"
  2. example to increase the heap size of JVM is ,its better to keep -Xmx to -Xms ration either 1:1 or 1:1.5 if you are setting heap size in your java application

    export JVM_ARGS="-Xms1024m -Xmx1024m"
  3. Next is use the Eclipse Memory Analyzer.

No comments:

Post a Comment