Navigation

RSS 2.0 New Entries Syndication Feed Atom 0.3 New Entries Syndication Feed

Show blog menu v

 

General

Use it

Documentation

Support

Sibling projects

RIFE powered

Valid XHTML 1.0 Transitional

Valid CSS!

Blogs : Archives

< Don't trust URLs!   JHighlight 1.0rc released >
How I got rid of java.lang.OutOfMemoryError on our server

Eliot blogged about getting OutOfMemory errors after some days of running a web application.

This happened to me too and I spent almost a week trying to track down the leak with a whole arsenal of tools ... and it turned out there was no leak.

Most JVMs allocate memory on the heap for almost everything, except for reflective data. That is put in a separate location which is a section of the heap that is reserved for permanent generation. This gets easily filled up when you dynamically load an unload classes, or have a large number of classes. I simply added the following options to the java executable and all my worries were gone:

-XX:PermSize=256M -XX:MaxPermSize=256M

My entire command for Sun's JVM looks like this now:

java -server -Djava.awt.headless=true -Xms1024M -Xmx1024M
     -XX:PermSize=256M -XX:MaxPermSize=256M

Hope this helps someone.

posted by Geert Bevin in Java on Apr 21, 2005 2:52 PM : 35 comments [permalink]
 

Comments

Re: How I got rid of java.lang.OutOfMemoryError on our server
Do you have any links to where I can find out more about reflective data being stored in a reserved area of the heap?

Thought you'd like to know I'm in the middle of trying "-XX: PermSize=256M -XX:MaxPermSize=256M" with my app to see if it solves the java.lang.OutOfMemoryError problem. I'll let you know how it goes.

Re: How I got rid of java.lang.OutOfMemoryError on our server
This is the best I could find: http://publib.boulder.ibm.com/infocenter/ws60help/index.jsp?topic=/com.ibm.websphere.nd.doc/info/ae/ae/tprf_tunejvm.html plus some blurbs on various blogs and sites.
Re: How I got rid of java.lang.OutOfMemoryError on our server
Well, if your app or libraries it depends on do dynamic class generation, your perm space problem could still be a memory leak. It would be a leak in the perm space, not the heap. (from personal experience)

Re: How I got rid of java.lang.OutOfMemoryError on our server
Indeed, it could, but this wasn't the case for me since the application has been happely running for several months. It just needed more memory than the default setting.
Re: How I got rid of java.lang.OutOfMemoryError on our server
Here's a good link with all(?) possible JVM arguments: http://blogs.sun.com/roller/resources/watt/jvm-options-list.html

Take a look at the links next to the "-XX:MaxPermSize=<value>" option. This one, http://java.sun.com/docs/hotspot/gc/ (Tuning Garbage Collection with the 1.3.1 Java Virtual Machine) might seem outdated but contains at least some usefull explanation about how the gc works and how the JVM's memory is used.

A very ugly hack that also works is to call 'System.gc()' in your code, and leave out the '-XX:+DisableExplicitGC' startup option for your server ;)

Re: How I got rid of java.lang.OutOfMemoryError on our server
Thanks for the link.

Unfortunately specifying the PermSize system properties didn't fix my problem. I think if I increased the size assigned that may reduce the frequency of my OutOfMemoryError.

Re: How I got rid of java.lang.OutOfMemoryError on our server
Sorry to hear that Eliot :(

I hope you find the solution soon, these things are really horrible to track down.

Re: How I got rid of java.lang.OutOfMemoryError on our server
if your perm space is filling up, you could have a leak w.r.t. classloaders or classes. yourkit makes a really good profiler that I use.
Re: How I got rid of java.lang.OutOfMemoryError on our server
Yeah I used YourKit too, there was no leak, just a whole lot of classes.
Re: How I got rid of java.lang.OutOfMemoryError on our server
We keep a ton of information about performance, performance tuning, at http://www.javaperformancetuning.com in our tips pages.
Re: How I got rid of java.lang.OutOfMemoryError on our server
You shouldn't have your min heap and max heap the same size. It's good for benchmarking since the garbage collector won't get called in a short test but your overall GCs will be longer. You can leave your max at 1 gig but your min should be set to something low but not so low that GC happens during startup of the app. The net affect should be more but shorter GCs resulting in a overall decrease in time spent garbage collecting. It's a different story though if normal usage of your application shoots the heap size straight up to the max and stays there forever. It helped for the app I was performance tuning since our memory usage really only hovered around 560M instead of the full gig allocated to it.
Re: How I got rid of java.lang.OutOfMemoryError on our server
Thanks for the tip Samus, I'll lower it a bit. I just figured that giving as much as possible and allocating it from the start would yield the best results. Guess I should have profiled it.
Re: How I got rid of java.lang.OutOfMemoryError on our server
Have you seen this?

http://www-1.ibm.com/support/docview.wss?rs=180&context=SSEQTP&uid=swg1PQ91787

We've been experiencing hidden memory leaks on WAS 5.1 and 5.1.1. In test enviroment, we implemented this fix and it seems to improve performance dramatically.

How I want to solve the java.lang.OutofMemoryError?
I am getting OutofMemory Exception in my adapter occasionally and the
adapter dies after a while, works only after it is restarted.
It does not look like Garbage collection threads issue, could be a different issue.Checked all the basic config stuff and other things. Need help.

The error log is like:

at com.wm.app.b2b.server.invoke.ServiEAIE1mPSOrderConsume.adapterServices:callN5500433
2006-03-15 00:19:19 CST WMERROR 7b728480b3eb11dab60e97d12c2ca88aNULL 7b728480b3eb11dab60e97d12c2ca88a1142403559609 btbib31.mmm.com:9340 [ART.118.5053] Adapter Runtime (Connection): Unable to get a connection to resource EAIE1mPSOrderConsume.adapterConnections:E1mPSOrderConn.
null
java.lang.OutOfMemoryError
>>>BasicData:message=null,date=Wed Mar 15 00:19:17 CST 2006,reason=null
java.lang.OutOfMemoryError
,exceptionClass=javax.resource.ResourceException,stack=javax.resource.ResourceException: null
java.lang.OutOfMemoryError

Re: How I got rid of java.lang.OutOfMemoryError on our server
How I got rid of it: Call .close() on all Statements. After I did that, both mysqld and java would run at a fairly constant memory usage level (before, they'd OOM at insane levels fairly quickly).
Re: How I got rid of java.lang.OutOfMemoryError on our server
One of my application resulted in this error. Can i use the solution suggested above to correct this error. Help..

java.lang.OutOfMemoryError
Mar 30, 2007 11:25:51 AM org.apache.coyote.tomcat5.CoyoteAdapter service
SEVERE: An exception or error occurred in the container during the request proce
ssing
java.lang.OutOfMemoryError
java.lang.OutOfMemoryError
Thanks for the link
This is somthing I need to try and see how userful it is.
Re: How I got rid of java.lang.OutOfMemoryError on our server
I had the same problem with memory, and using the -Xmx argument, I got rid of it. But I want to ask you something guys: When I use, in a big for loop, a statement like:
for ( .. ) {
AnObject o = new AnObject();
}

is more memory consuming than using:

AnObject o;
for ( ... ) {
o = new AnObject();
}

?

Thanks in advance.
Re: How I got rid of java.lang.OutOfMemoryError on our server
hi to address the same issue in j2sdk what could be done. Could someone please help on this?
Re: How I got rid of java.lang.OutOfMemoryError on our server
hi i'm sorry i dint give any details. i'm running jsp's using JBoss server and getting the OutOfMemoryError. i'm using j2sdk1.4

Thanks in advance :)
Re: How I got rid of java.lang.OutOfMemoryError on our server
I am experiencing java.lang.OutOfMemoryError conditions even when my usage of heap is nowhere near the -Xmx value. Would increasing the MaxPermSize help.
Re: How I got rid of java.lang.OutOfMemoryError on our server
Hey guys,
I am new java,working Biztalk server applications.
I am trying to connet Siebel backend system using siebel adapter.
Siebel adapter exposing some java api's (.jar files) to the Biztalk server applications.
It is throwing out of memory exception if we stress the system with 2000 msgs.
I am trying to increase my JVM heap memory size,but i couldn'd find the exact place to updates the settings.
I am not running any web servers in my machine except Java runtime.

Can anyone help us?
Thanks,
Nage
Re: How I got rid of java.lang.OutOfMemoryError on our server
Very interesting article for java beginners
Re: How I got rid of java.lang.OutOfMemoryError on our server
reducing the comporession level DID indeed work! thnx so much for the suggestion.
java.lang.OutOfMemoryError on firs time loading
Hi,
I am not even sure whether this is the right place to ask for answers/suggestions.
Anyway, I am using JDev10g connecting to Oracle10g db. What the page does is to do a simple retrieval from db and display. The weird thing is if I login the first time and go directly to search on that page, i will get java.lang.OutOfMemoryError.

If I go to other pages/module and execute a search (with results even for thousands of records) and then go back to the problematic page,I will get results in a blink.

I can't think of why this happened. I am really hoping if anyone have any idea.

Thanks in advance.. realllly need help on this
java.lang.OutOfMemoryError on firs time loading
Hi,
I am not even sure whether this is the right place to ask for answers/suggestions.
Anyway, I am using JDev10g connecting to Oracle10g db. What the page does is to do a simple retrieval from db and display. The weird thing is if I login the first time and go directly to search on that page, i will get java.lang.OutOfMemoryError.

If I go to other pages/module and execute a search (with results even for thousands of records) and then go back to the problematic page,I will get results in a blink.

I can't think of why this happened. I am really hoping if anyone have any idea.

Thanks in advance.. realllly need help on this
Re: How I got rid of java.lang.OutOfMemoryError on our server
Hi,

i am getting this problem when i get a wrong login request on my system from the client,using tcp/ip clients are connected to the system, we do validation first and den writing the request data to sockets.this is implimented by creating a single thread for a single user request.the problem occurs wen my system bombarded with wrong login request time_wait comes and at a certain level the socket stop listening and i get the message java.lang.OutOfMemoryError in errorlog,
hope you could sujjest me any solution for this

thanks and regards
manish
Re: How I got rid of java.lang.OutOfMemoryError on our server
hello

Please can anyone help me with this error I'm using maximo 5.2 with weblogic 7.2 and when i login to maximo and try to get a record it give me this error.




MboSet getZombie :java.lang.OutOfMemoryError
java.lang.OutOfMemoryError
<<no stack trace available>>
Tue Mar 11 13:03:16 AST 2008 MboSet getZombie :java.lang.OutOfMemoryError
java.lang.OutOfMemoryError
<<no stack trace available>>
java.lang.NullPointerException
at psdi.mbo.MboSet.hasQbe(MboSet.java:4502)
at psdi.mbo.Mbo.getMboSet(Mbo.java:2294)
at psdi.app.labor.Labor.getMboSet(Labor.java:1409)
at psdi.mbo.Mbo.getMboSet(Mbo.java:2353)
at psdi.mbo.MboSet.getMboSetForAttribute(MboSet.java:6265)
at psdi.mbo.MboSet.getQbe(MboSet.java:6244)
at psdi.mbo.MboSet.getQbe(MboSet.java:4490)
at psdi.jsp.beans.MboSetBean.getQbe(MboSetBean.java:1222)
at psdi.jsp.beans.JavaScriptGenerator.printScriptFunctions(JavaScriptGen
erator.java:1259)
at psdi.jsp.beans.JavaScriptGenerator.generateScript(JavaScriptGenerator
.java:85)
at jsp_servlet._jsp._app._labor.__search._jspService(__search.java:1023)

at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:1058)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:401)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:445)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:306)
at weblogic.servlet.internal.RequestDispatcherImpl$ForwardAction.run(Req
uestDispatcherImpl.java:342)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServic
eManager.java:780)
at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispat
cherImpl.java:252)
at weblogic.servlet.jsp.PageContextImpl.forward(PageContextImpl.java:132
)
at psdi.jsp.util.Util.forward(Util.java:2014)
at psdi.jsp.util.Util.forwardToFindPage(Util.java:1375)
at psdi.jsp.common.Navigate.findInitial(Navigate.java:397)
at psdi.jsp.common.CommonActions.initializeapplication(CommonActions.jav
a:61)
at psdi.jsp.app.labor.Actions.initializeapplication(Actions.java:59)
at java.lang.reflect.Method.invoke(Native Method)
at psdi.jsp.common.NavbarHandler.action(NavbarHandler.java:155)
at psdi.jsp.common.NavbarHandler.handleAction(NavbarHandler.java:95)
at psdi.jsp.common.NavbarHandler.handleRequest(NavbarHandler.java:415)
at java.lang.reflect.Method.invoke(Native Method)
at psdi.jsptags.HandleRequestTag.doEndTag(HandleRequestTag.java:104)
at jsp_servlet._jsp._app._labor.__main._jspService(__main.java:283)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:1058)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:401)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:445)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:306)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:5445)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServic
eManager.java:780)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:3105)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2588)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:213)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:189)
Re: How I got rid of java.lang.OutOfMemoryError on our server
Can any pls please tell me what exactly command we have to fire from which particular directory in order to increase heap size.
my use is not that much big as per my xmx value.
Re: How I got rid of java.lang.OutOfMemoryError on our server
Helo dear all , When i was trying to download file with size grater than 40mb application shows the following error 500 Internal Server Error java.lang.OutOfMemoryError i am using application server 10g IAS. when i am using same apllication in Tomcat 6 we can download the file with out erorr. If any one had an idea about this please post in this site or dend to my email addess Also i try to apply above mentioned solution in both jdk, jre path ( C:\Program Files\Java\jdk1.6.0_03> java -server -Djava.awt.headless=true -Xms1024M -Xmx1024M -XX:PermSize=256M -XX:MaxPermSize=256M showing error Error: no `server' JVM at `C:\PROGRAM FILES\ORACLE\JRE\1.3.1\bin\server\jvm.dll'. } Thanks in advance
Re: How I got rid of java.lang.OutOfMemoryError on my mobile
i got this error message on my mobile(nokia 5310) .i want to get rid of this.
seem that no one has come across this on a mobile but i need help ASAP.

thanks in advance.:)
Re: How I got rid of java.lang.OutOfMemoryError on our server
:o8):p:|:/:D:(:'(=):-);):)
Re: How I got rid of java.lang.OutOfMemoryError on our server
:) Thanks a lot.
I used your solution in a software running in our company. It had been running for a long time without issues until now.
Anyways, it's fixed now... thanks

java -Xms1024M -Xmx1024M -XX:permSize=256M -XX:MaxPermSize=256M DCapture

I had to put the parameters before the process name... otherwise it didn't work.
Re: How I got rid of java.lang.OutOfMemoryError on our server
I have The Some problem with Nokia 5310 XpressMusic I'm glad I am not The Only One Here ;):):-)=):(:'(
Re: How I got rid of java.lang.OutOfMemoryError on our server
dude i really need help here.... i can play games on my Nokia 5310 cause of this error.. HELP.!!!

Add a new comment

Comments on this blog entry have been closed.

< Don't trust URLs!   JHighlight 1.0rc released >
 
 
 
Google
rifers.org web