File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes OutOfMemoryError: PermGen space - pl help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "OutOfMemoryError: PermGen space - pl help" Watch "OutOfMemoryError: PermGen space - pl help" New topic

OutOfMemoryError: PermGen space - pl help

chelakkad ben
Ranch Hand

Joined: Feb 09, 2005
Posts: 62
The servlet throws this error message..

2005-05-16 20:55:09 StandardWrapperValve[server_flt]: Servlet.service() for servlet server_flt threw exception
java.lang.OutOfMemoryError: PermGen space

how to rectify this prob ...what modification should i make in my servlet program to avoid this error?
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

There are usually two causes of this problem:
1) not enough memory
2) infinite loop, usually caused by JSP-A including JSP-B including JSP-A etc etc.

chelakkad ben
Ranch Hand

Joined: Feb 09, 2005
Posts: 62
Hello David
thank you for the reply.
Is there any way to get over it? Can you be a little more specific?
Thank you for the info.
In fact its an applet-servlet comm appl that i am running. The servlet creates the object and is send to the applet where it is displayed. The applet then creates an object and is sent back to servlet for updating the database. So its objects being sent back and forth.

Again if the object created at the applet is set to null
sub s = new sub(id,add,zip) ;
s = null;
Is object s a candidate for garbage collection?
What i mean is, if i no longer want the object s , is there any way to completely(explicitly) remove it from the memory?

Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Does the user really need all that data in the applet, at once?
If not, I'd consider putting a LIMIT or ROWNUM clause in your query to cut down the number of rows sent to the applet. Let the user query again for the next block of rows as s/he needs them.

If you do really need to send all of that data at once, then you should try increasing the heap size in the JVM. Google on -Xms and -Xmx for more information.
If you're running Tomcat on windows and you've installed the "start menu" items, you can alter the memory settings by going to Start -> Programs -> Apache Tomcat -> Configure Tomcat -> click on the Java or Memory tab.
There are fields for the initial and maximum memory settings.

You'll then have to deal with streaming all of that data over the network and then your user will have to deal with all of that data within the JVM under which the applet is running. If it's blowing up the server's JVM it'll probably cause you headaches on the client's JVM as well.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
chelakkad ben
Ranch Hand

Joined: Feb 09, 2005
Posts: 62
Hello Ben
Thanks so much for that info. The client will be downloading a vector containing around 300 records(objects)- worst case . I am using vector so that the client can scroll through the records (by cliking next or previous buttons).As most of the clients are using win98, so using CachedRowSet may not work, i think.Any better idea??
As you mentioned, records can be limited to about 10 each.
Shall also try increasing heap size in jvm.
Using Apache2.0.52 - mod_jk2 - Tomcat 5.0.28 on win2k.
I agree. Here's the link:
subject: OutOfMemoryError: PermGen space - pl help
jQuery in Action, 3rd edition