Friday, September 2, 2011

2 solution of java.lang.OutOfMemoryError in Java

Every one in java development face java.lang.OutOfMemoryError now and then, OutOfMemoryError in Java is one problem which is more due to system's limitation (memory) rather than due to programming mistakes in most cases though in certain cases you could have memory leak which causing OutOfMemoryError. I have found that even though java.lang.OutOfMemoryError is quite common basic knowledge of its cause and solution is largely unknown among junior developers. In this article we will explore what is java.lang.OutOfMemoryError; Why OutOfMemoryError comes in Java application, different type of OutOfMemoryError and How to fix OutOfMemoryError in Java. This article is purely meant to provide basic knowledge of java.lang.OutMemoryError and won't discuss profiling in detail.

What is java.lang.OutOfMemoryError in Java

java.lang.OutOfMemoryError in Java, PermGen space or heap spaceOutOfMemoryError in Java is a subclass of java.lang.VirtualMachineError and JVM throws java.lang.OutOfMemoryError when it ran out of memory in heap. OutOfMemoryError in Java can come any time in heap mostly while you try to create an object and there is not enough space in heap to allocate that object. javavdoc of OutOfMemoryError is not very informative about this though.

Types of OutOfMemoryError in Java

I have seen mainly two types of OutOfMemoryError in Java:

1) Java.lang.OutOfMemoryError: Java heap space
2) Java.lang.OutOfMemoryError: PermGen space

Though both of them occur because JVM ran out of memory they are quite different to each other and there solutions are independent to each other.

Difference between "java.lang.OutOfMemoryError: Java heap space" and "java.lang.OutOfMemoryError: PermGen space"

If you are familiar with different generations on heap and How garbage collection works in java and aware of new, old and permanent generation of heap space then you would have easily figured out this OutOfMemoryError in Java. Permanent generation of heap is used to store String pool and various Meta data required by JVM related to Class, method and other java primitives. Since 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. Important point to remember is that it doesn't depends on –Xmx value so no matter how big your total heap size you can ran OutOfMemory in perm space. Good think is you can specify size of permanent generation using JVM options "-XX:PermSize" and  "-XX:MaxPermSize" based on your project need.

One small thing to remember is that "=" is used to separate parameter and value while specifying size of perm space in heap while "=" is not required while setting maximum heap size in java, as shown in below example.

export JVM_ARGS="-Xmx1024m -XX:MaxPermSize=256m"


Another reason of "java.lang.OutOfMemoryError: PermGen" is memory leak through Classloaders and it’s very often surfaced in WebServer and application server like tomcat, webshere, glassfish or weblogic. In Application server different classloaders are used to load different web application so that you can deploy and undeploy one application without affecting other application on same server, but while undeploying if container some how keeps reference of any class loaded by application class loader than that class and all other related class will not be garbage collected and can quickly fill the PermGen space if you deploy and undeploy your application many times. "java.lang.OutOfMemoryError: PermGen” has been observed many times in tomcat in our last project but solution of this problem are really tricky because first you need to know which class is causing memory leak and then you need to fix that. Another reason of OutOfMemoryError in PermGen space is if any thread started by application doesn't exit when you undeploy your application.

These are just some example of infamous classloader leaks, anybody who is writing code for loading and unloading classes have to be very careful to avoid this. You can also use visualgc for monitoring PermGen space, this tool will show graph of PermGen space and you can see how and when Permanent space getting increased. I suggest using this tool before reaching to any conclusion.

Another rather unknown but interesting cause of "java.lang.OutOfMemoryError: PermGen" we found is introduction of JVM options "-Xnoclassgc". This option sometime used to avoid loading and unloading of classes when there is no further live references of it just to avoid performance hit due to frequent loading and unloading, but using this option is J2EE environment can be very dangerous because many framework e.g. Struts, spring etc uses reflection to create classes and with frequent deployment and undeployment you can easily ran out of space in PermGen if earlier references was not cleaned up. This instance also points out that some time bad JVM arguments or configuration can cause OutOfMemoryError in Java.

So conclusion is avoid using "-Xnoclassgc" in J2EE environment especially with AppServer.


Tomcat to Solve OutOfMemoryError in PermGen Space

From tomcat > 6.0 onward tomcat provides memory leak detection feature which can detect many common memory leaks on web-app perspective e.g ThreadLocal memory leaks, JDBC driver registration, RMI targes, LogFactory and Thread spawned by web-apps. You can check complete details on htp://wiki.apache.org/tomcat/MemoryLeakProtection you can also detect memory leak by accessing manager application which comes with tomcat, in case you are experiencing memory leak on any java web-app its good idea to run it on tomcat.

How to solve java.lang.OutOfMemoryError: 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. This is my preferred solution when I get OutOfMemoryError in Eclipse, Maven or ANT while building project because based upon size of project you can easily ran out of Memory.here is an example of increasing maximum heap size of JVM, Also 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"

2) Second way to resolve OutOfMemoryError in Java is rather hard and  comes when you don't have much memory and even after increase maximum heap size you are still getting java.lang.OutOfMemoryError, in this case you probably want to profile your application and look for any memory leak. 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.

How to solve java.lang.OutOfMemoryError: PermGen space

As explained in above paragraph this OutOfMemory error in java comes when Permanent generation of heap filled up. To fix this OutOfMemoryError in Java you need to increase heap size of Perm space by using JVM option   "-XX:MaxPermSize". You can also specify initial size of Perm space by using    "-XX:PermSize" and keeping both initial and maximum Perm Space you can prevent some full garbage collection which may occur when Perm Space gets re-sized. Here is how you can specify initial and maximu Perm size in Java:

export JVM_ARGS="-XX:PermSize=64M -XX:MaxPermSize=256m"

Some time java.lang.OutOfMemoryError  in Java gets tricky and on those cases profiling remain ultimate solution.Though you have freedom to increase heap size in java, it’s recommended that to follow memory management practices while coding and setting null to any unused references.
That’s all from me on OutOfMemoryError in Java I will try to write more about finding memory leak in java and using profiler in some other post. Please share what is your approach to solve java.lang.OutOfMemoryError in Java.


Important Note: From Tomcat > 6.0 onward tomcat provides memory leak detection feature which can detect many common memory leaks on Java application e.g ThreadLocal memory leaks, JDBC driver registration, RMI targes, LogFactory and Thread spawned by webapps. You can check complete details on htp://wiki.apache.org/tomcat/MemoryLeakProtection. You can also detect memoy leak by accessing manager application which comes with tomcat, in case you are experiencing memory leak on any java webapp its good idea to run it on tomcat to find out reason of OutOfMemoryError in PermGen space.

Tools to investigate and fix OutOfMemoryError in Java

Java.lang.OutOfMemoryError is a kind of error which needs lot of investigation to find out root cause of problem, which object is taking memory, how much memory it is taking or finding dreaded memory leak and you can't do this without having knowledge of available tools in java space. Here I am listing out some free tools which can be used to analyze heap and will help you to find culprit of OutOfMemoryError

1) Visualgc
Visualgc stands for Visual Garbage Collection Monitoring Tool and you can attach it to your instrumented hostspot JVM. Main strength of visualgc is that it displays all key data graphically including class loader, garbage collection and JVM compiler performance data.
The target JVM is identified by its virtual machine identifier also called as vmid. You can read more about visualgc and vmid options here.

2) Jmap
Jmap is a command line utility comes with JDK6 and allows you to take a memory dump of heap in a file. It’s easy to use as shwon below:

jmap -dump:format=b,file=heapdump 6054

Here file specifies name of memory dump file which is "heapdump" and 6054 is PID of your Java progress. You can find the PDI by using "ps -ef” or windows task manager or by using tool called "jps"(Java Virtual Machine Process Status Tool).

3) Jhat
Jhat was earlier known as hat (heap analyzer tool) but it is now part of JDK6. You can use jhat to analyze heap dump file created by using "jmap". Jhat is also a command line utility and you can rum it from cmd window as shown below:

jhat -J-Xmx256m heapdump

Here it will analyze memory-dump contained in file "heapdump". When you start jhat it will read this heap dump file and then start listening on http port, just point your browser into port where jhat is listening by default 7000 and then you can start analyzing objects present in heap dump.

4) Eclipse memory analyzer
Eclipse memory analyzer (MAT) is a tool from eclipse foundation to analyze java heap dump. It helps to find classloader leaks and memory leaks and helps to minimize memory consumption.you can use MAT to analyze heap dump carrying millions of object and it also helps you to extract suspect of memory leak. See here for more information.


Here are some of my other post on Java you may find interesting:

52 comments :

Anonymous said...

Hi, I am getting below OutOfMemoryError:

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

while copying content from one Collection to Another, is there anyway I know how much memory I need for this operation.

Ronit said...

I have a tomcat server which is throwing outofmemory exception

java.lang.OutOfMemoryError: PermGen space
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)

while I am restarting it. Please help

Javin@ string vs Stringbuffer in Java said...

try to increase heap memory of tomcat in catalina.bat or catalina.sh.

Anonymous said...

Heap & Permgen space configuration for Tomcat

http://www.zulutown.com/blog/2009/03/12/solving-tomcat-outofmemoryerror-heap-space-and-permgen-space/

Anonymous said...

you should also include "java.lang.OutOfMemoryError: GC overhead limit exceeded" , this error comes when Garbage Collector spends excessive amount of time doing GC and recovers a little, say 2% of heap. possible reason for this OutOfMemoryError could be that you are creating lots of temporary object inside loop or recursive function. to fix this review your code and fix the cause or else you can try by increasing maximum heap size using -Xmx. you can also disable this alert by following JVM options : -XX:-UseGCOverheadLimit

Sanjeev said...

very nice post. our application was also getting stuck due to OutOfMemoryError due to use of large number of String. I solved it by minimizing number of String object by StringBuffer. Now this setting of Perm generation will also be helpful to make application more efficient.
Thanks a lot.
Sanjeev
all-technicals.blogspot.com

G. Ramamurthy said...

I am getting OutOfMemoryError in tomcat after deploying my application and accessing it.

Exception in thread ""http-bio-8084"-exec-80" java.lang.OutOfMemoryError: PermGen space
Exception in thread "ContainerBackgroundProcessor[StandardEngine[Catalina]]" java.lang.OutOfMemoryError: PermGen spac

Can someone please help me.

JP @ java.lang.unsupportedclassversionerror said...

Hi Ramamurthy, from your description it looks like a classloader leak to me. try deploy -undeploy operation few times and if it appears it means it sure short classloader leak. now to fix that you need to find what is causing this leak, which may be tricky, you can use the tools I have listed or you can also try asking on javaranch or tomcat forums.

Anonymous said...

Rama are you using JDBC driver, I was suffering from same problem but thanks to spring it warned me.SEVERE: The web application [/OutOfMemoryTest] registered the JDBC driver [oracle.jdbc.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

Anonymous said...

Sorry it was not Spring but Tomcat who was warned me. org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc forcibly unregistered the JDBC driver to prevent memory leak.

Javin @ ClassNotFoundException in Java said...

@Anonymous, thanks for your valuable comment. Tomcat has good support to detect memory leak and warn agaginst unregisted JDBC driver which can cause java.lang.OutOfMemoryError:PermGen Space

Jess said...

Another way to solve "java.lang.OutOfMemoryError:PermGen Space " in tomcat due to JDBC driver is moving jdbc drivers jar to tomcat lib and let common classloader load the driver and not the webapp loader.

javadude said...

Hi, I am getting java.lang.OutOfmemoryError java heap space while reading data from database and manipulating it on my program. I load a large resultset which contains 1000 rows and it seems Ojbects are getting larger than heap. please help.

Anonymous said...

we are getting java.lang.OutOfMemoryError: unable to create new native thread , do you know what causing this and how we can fix this outofmemoryerror.

Javin @ UnsupportedClassVersionError in Java said...

hi Anonymous java.lang.OutOfMemoryError: unable to create new native thread Exception comes when a request to create a new thread can not be full filled due to no memory. try increase PermGen Space by using command export JVM_ARGS="-XX:PermSize=64M -XX:MaxPermSize=256m" and let us know how it goes.

Anonymous said...

What is difference between OutOfMemoryError in PermGen and OutOfMemoryError in Java Heap , isn't it Perm Gen is part of Java Heap and if Heap runs outofmemory than how can Perm Gen space remain empty, please help?

Javin @ ArrayList vs Vector in java said...

@Anonymous As I explained them in this OutOFMemoryError tutorial they are entirely different. yes Perm Gen space is part of Java heap but its a separate generation and space is not adjusted with other region in heap. also different parameters are used to define size of PermGen space and Heap space in Java.

Peng said...

I am getting java.lang.OutOfMemoryError: Java heap space by java compiler javac while compiling my project. my project is little large interms of resource and classes and contains lots of xml mappings. please suggest hot to resolve outofmemoryerror in javac ?

EclipseUser said...

I was getting ava.lang.OutOfMemoryError: PermGen space in Eclipse 3.7 and adding
-XX:MaxPermSize=512M in eclipse.ini file solves that for me.Thanks for clear explanation of OutOfMemoryError in PermGen Space.

Peter Lawrey said...

I often see OutOfMemoryError: Out of swap space.

amidst said...

I am using springsource and am getting same problem.
not getting where to execute the command.

Javin @ serialization interview questions said...

@amidst, Can you please explain where exactly you are getting java.lang.OutOfMemoryError, would be great if you post exact error, as there are different types of OutOFMemroyError in Java and different ways to handle them.

Javin @ hashtable example java said...

@Peter, Can you please let us know when do you get OutOfMemoryError: Out of swap space , I never got that, so it good to know.Thanks for your comment.

Anonymous said...

> This is tough solution and requires some time to analyze and find memory leaks.

There is a tool called Plumbr that does the tough job for you: www.plumbr.eu

It is currently offered for free for a 45-day period.

Bhavesh said...

Hi Javin, I am getting out of memory error still memory is available(please refer below logs). Another thing is GC can not recovered at least 2% of memory so getting also "OutOfMemoryError: GC overhead limit exceeded". Can you please suggest how to solve it.

Logs are:
[Full GC 707328K->699175K(808320K), 1.9262490 secs]
[Full GC 707328K->701939K(808320K), 1.9376400 secs]
[Full GC 707328K->704226K(808320K), 1.9537460 secs]
[Full GC 707328K->700242K(808320K), 2.4339400 secs]
[Full GC 707327K->707326K(808320K), 1.9606190 secs]
[Full GC 707327K->707327K(808320K), 1.9245120 secs]
[Full GC 707327K->707327K(808320K), 1.9144290 secs]
[Full GC 707327K->704646K(808320K), 1.8971880 secs]
Exception in thread "Thread AUTH Main" java.lang.OutOfMemoryError: Java heap space
at elitejradius.server.OnlineAuthSocket.readdata(OnlineAuthSocket.java:139)
at elitejradius.server.OnlineAuthSocket.run(OnlineAuthSocket.java:107)
at java.lang.Thread.run(Thread.java:619)
[Full GC 707327K->707327K(808320K), 1.8988010 secs]
[Full GC 707327K->704903K(808320K), 2.5105980 secs]
Exception in thread "Auth-Sub-Process 132" java.lang.OutOfMemoryError: GC overhead limit exceeded
at java.lang.String.substring(String.java:1939)
at java.lang.String.substring(String.java:1904)
at java.io.File.getName(File.java:401)
at java.io.UnixFileSystem.getBooleanAttributes(UnixFileSystem.java:229)
at java.io.File.exists(File.java:733)

Sunita said...

Hi Javin,
I am getting
java.lang.OutOfMemoryError: Out of swap space
in Linux on HotSport Virtual Machine, complete exception text is
Exception in thread "main" java.lang.OutOfMemoryError: requested 45778 bytes for ChunkPool::allocate. Out of swap space

Can you please let us know What is cause of this OutOfMemoryError as it looks different than OutOfMemoryError Perm Gen or Java Heap.

Javin @ static factory in java said...

@Bhavesh , possible cause of java.lang.OutOfMemoryError: GC overhead limit exceeded is that it comes if Full GC takes longer time than usual and amount of memory available in both new generation and old generation is smaller than there specified limit. -XX:+UseGCOverheadLimit JVM option in Java 6 specify the limit the proportion of the VM's time that is spent in GC before an OutOfMemory error is thrown. play with this option if it help or try to find out cause of long GC duration.

Gina said...

hello
I really didn't understand the text very will it is clear text but for beginner like me It is confused somehow
where I have to put this sentence "-XX:PermSize"?
I'm using jgrasp in programming but not for web applications
the error was:Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "main"
I read som other subjects they said to use run arguments then text box will appears then write for example "-Xmx1024m" but nothing happened!
if you can give me a hint.
thanks in advance (:.

Javin @ java.lnag.NoSuchElementException said...

Hi Gina, I don't know about jgrasp. are you using any IDE like Eclipse or Netbeans? anyway on very basic level, every Java program starts with "java" command in both Windows and Unix. -XX:PermSize is a command line argument to "java" command.

Gina said...

yes I'm using Netbeans
could you pleas tell me how exactly I can increase the memory size?
I'm sorry for bothering you, I really appreciate your help.

Javin @ Invalid Column Exception SQL Java said...

Hi Gina, If you are using Netbeans,then Select Project in Project explorer (I hope its Java Project) and right click->Properties. Then look for run time settings, provide your Java memory settings there.

Gina said...

it didn't work , may I have done some thing wrong
any way thanks for your help.
I have removed some unnecessary lists & it work good now ^_^.

Shri said...

VisualVM and Jconsole are good applications for analyzing memory leaks , deadlocks and getting thread dump or snapshot. They are built in JDK which makes them free and powerful.

James said...

Memory leak in PermGen space is a serious problem and require lot for attention, investigation and troubleshooting as author says "Its hard part" but simply increasing PermGen space is not a solution you need to identity the cause first before applying any solution. blog post on Oracle https://blogs.oracle.com/fkieviet/entry/classloader_leaks_the_dreaded_java has great discussion on finding and troubleshooting classloader leaks which is primary cause of running OutOfMemory in PermGen .

Kavita said...

Hello Sir, We are getting java.lang.outofmemoryerror permgen space in Weblogic Server. we are using following JVM parameters:
-Xms2G -Xmx2G -XX:PermSize=512m -XX:MaxPermSize=512m -XX:+UseParallelGC -Xnoclassgc
. I am suspecting memory leak issue because we are using ThreadLocal variable or as you may mentioned may be ClassLoader Leak as we are also using JDBC API but I have no clue how to check PermGen space and which objects are stored in PermGen memory. any help

James said...

@Kavita, try to remove -Xnoclassgc parameters as it prevent classes from PermGen not to be garbage collected which results in java.lang.OutOfMemoryError: PermGen space. I guess -Xnoclassgc also one of the reason of "java.lang.OutOfMemoryError: GC overhead limit exceeded" which I am currently investigating.

Anonymous said...

Hello, We are getting "java.lang.OutOfMemoryError: thread creation failed" in Eclipse IDE while working on Android application. I am not sure whether OutOfMemory is related to Eclipse or Android, please advise.

Pietersan said...

Nice article.... I think OutOfMemoryError is a Fatal Error in VM and from Java 6 onwards Virtual machine produce complete stack trace of OutOfMemoryError. You can also use JVM parameter -XX:OnOutOfMemoryError= to run any command in an event of first OutOfMemoryError thrown by JVM. You can also generate heap dump on OutOfMemoryError by using -XX:+HeapDumpOnOutOfMemoryError and -XX:HeapDumpPath= to specify directory where heap dump needs to be created. With this much information its easy to diagnose any memory leak in Java, but as you said most of the time just increasing size of heap or permgen memory area.

Anonymous said...

One tip to solve OutOfMemoryError in heap space and permgen is to look output of full garbage collection and find out what triggering it whether its triggered by full permgen space and or or full old generation space in heap. that will give clue for sure.

Anonymous said...

Hi,
Most Out of memory errors are from memory leaks introduced by java developers in the java application code/programs, as the default heap size is enough to handle almost all possible application scenarios,
you can get prompt response and possible solutions for all your java out of memory errors at http://loasoftwares.com/servicesLink.action#loaTechnicalService

Anonymous said...

Hi,

If you still face the problem after following the above methods, like i have faced after performing given below step and also tried to increase the values from 18 to 512 and from 512 to 1024
"-vmargs -XX:PermSize=128M -XX:MaxPermSize=512M "

but still i was facing problem then i had deleted the Build files under bld folder and increase the the size upto 512M.
It solves my problem.

Anonymous said...

OUTOFMEMORYERROR: Correr el proyecto desde UIWidgetBase -> build.xml -> Ant build...; luego correrlo normal como siempre "Open external tools dialogs...". Con eso se solucionó el error por arte de magia nada del otro mundo. Nada de instalar de nuevo el ID o de crear workspaces. Lo solucione con algo mas facil, espero que a uds tambien les funcione. "Workshop for Weblogic"

Anonymous said...

There are lot more about java.lang.OutOfMemoryError than java.lang.OutOfMemoryError: Java heap space and java.lang.OutOfMemoryError: PermGen space. First of all Java 8 has removed PermGen space and introduced Meta space, so be ready for a new kind of OUTOFMEMORYERROR in Java 8. Apart from these big two there are couple of more kind of this, e.g. :
java.lang.OutOfMemoryError: GC overhead limit exceeded
java.lang.OutOfMemoryError: unable to create new native thread
java.lang.OutOfMemoryError: Requested array size exceeds VM limit
java.lang.OutOfMemoryError: request bytes for . Out of swap space?
java.lang.OutOfMemoryError: (Native method)

which all comes with different reasons e.g. GC overhead limit exceeded comes when Garbage Collector spends more time collecting it but not able to collect enough.

Satyanarayan said...

Hello there, We are getting java.lang.OutOfMemoryError OUT OF SWAP SPACE in our JBoss server, exact error is this :

Exception in thread "main" java.lang.OutOfMemoryError: requested 8679869200bytes for Chunk ::new. Out of swap space? and our JVM crashes. I have tried increasing both Java Heap memory and PermGen Space memory by -Xmx and -XX:MaxPermSize, upto 3GB, Since we are running on Solaris 32-bit Machine and our JVM is also 32-bit JVM with JRE version Java 6 update 20. Any pointer would be helpful.

Sonia said...

I am getting java.lang.OutOfMemoryError: Map failed, while creating a memory mapped file of 2GB. This exception is thrown when FileChannel trying to call map() method. Since I am running on 64-bit machine and have enough RAM almost 6GB to support this Memory mapped file, I am wondering why Java throwing java.lang.OutOfMemoryError: Map failed.

Please let me know how to fix this error, any JVM option to solve this?

babyhudson said...

I have this error message. And I am not really that techie like any of the guys above. May I know if removing java from the program, refreshing and reinstalling java solve the problem?

Kapil said...

Hi,
I got OutOFMemoryError in one of the thread but after 30 mins another thread ran as usual. Is it possible that even after getting OutOfMemoryError: Java heap space, the application still runs?

Dheeraj said...

Hi Javin Sir

I have a question/scenario that i want to ask/share with you.
I am facing following issue on production server:
There are two production server not virtually connected totally different machine having different database and different IP, but both are working under one load balancer. OS is Windows server 2003. RAM 16GB.
JBoss configuration: 5.1, heap size 1024mb.
We have a servlet (Web Container we are using is JBoss) which takes request coming from mobile phones, process it (which is lengthy process) then communicate with our server (MEAP server, built using C and C++) using socket. This MEAP server executes lots of queries on database (Oracle) also call webservices if necessary and respond to the servlet, then servlet makes a proper response and give it back to the mobile phone. But when production server is running under lots of load (25000 requests per day), JBoss is getting down with "java.lang.OutOfMemoryError unable to create new native thread".
What i have done :
1. Check system log which is clean when this issue occure.
2. Check db connections. (But we are not executing queries from servlet).
3. Check task manager java process takes more than 700mb i dont know why but there are two java processes and both are taking more than 500mb each. I dont know why but our MEAP server which is handling db connections and webservice calls having lots of loads, takes much less memory than java process.
4. I have taken heap dump and also install eclipse memory analyzer but dont know how to check memory leaks if any are there, so please guide me with that.

I am fail to find root cause i also don't know much about tools, i don't know whether the problem is in servlet or in server environment or in concurrency.
If you want additional information i would like to share with you.
Please help me if you have time.

Javin Paul said...

Hi Dheeraj, Operating systems have limits on the number of threads that you can create, I think your application/JBoss is violating that limit. Check how many threads are running when this error comes, you can use command ps -eLF| grep -c java and try to configure maximum number of thread, may be JBoss might have config, you need to search for that. If anyone has faced this issue previously or know how to configure JBoss to handle such load, please let us know. I will also post if I come across exact reason or configuration change required to solve this error in your scenario.

Amit kr. Paul said...

"-Xmx1024m" (nothing happened)

Anonymous said...

Most of time it causes due to unnecessary stuff deployed at server , before applying any war file first clean all tmp and work stuff. it also helps to avoid outofmemory error

Anonymous said...

Set this setting in wrapper.conf file located in manageengine\server\default\conf
wrapper.java.initmemory=128 Maximum Java Heap Size (in MB) wrapper.java.maxmemory=512

Post a Comment