Hi Friends.......
I found java.lang.OutOfMemoryError in my code, How i will handle it. Why it is occur and what are the possible reasons for it.
Thanks........
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Chintan RathodPosted Dec 24, 2011, 12:27 AM
OutOfMemoryError in Java is problem which is more due to system's limitation (memory) rather than due to programming mistakes. You could have memory leak which causing OutOfMemoryError.
Types:
1) Java.lang.OutOfMemoryError: Java heap space
2) Java.lang.OutOfMemoryError: PermGen space
In most of JVM default size of Perm Space is around "64MB" you can easily ran out of memory if you have too many classes or huge number of Strings in your project.
Good think is you can specify size of permanent generation using JVM options "-XX:PermSize" and "-XX:MaxPermSize" based on your project need.
export JVM_ARGS="-Xmx1024m -XX:MaxPermSize=256m"
In case of Java Heap Space...
1) Easy way to solve OutOfMemoryError in java is to increase the maximum heap size by using JVM options "-Xmx512M", this will immediately solve your OutOfMemoryError.
export JVM_ARGS="-Xms1024m -Xmx1024m"
2)You can use Eclipse Memory Analyzer to examine your heap dump or you can use any profiler like Netbeans or JProbe. This is tough solution and requires some time to analyze and find memory leaks.
Available Tools:
1) Visualgc
2) Jmap
3) Jhat
4) Eclipse Memory Analyzer
Vikas MishraPosted Dec 24, 2011, 5:53 AM