• Post Reply Bookmark Topic Watch Topic
  • New Topic

Root causes of Java.lang.OutOfMemoryError: PermGen space  RSS feed

 
David Brossard
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm running web services within the axis engine contained in a tomcat server. I unfortunately started running into Java.lang.OutOfMemoryError: PermGen space errors.

My question is two-fold:
1. What can cause this?
2. How can I monitor my JVM in order to detect the root cause?

The only potential problem I can think of is file access (open / read / write) and process creations.
 
Srinivas Kalvala
Ranch Hand
Posts: 257
Firefox Browser Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Can you give yours JVM startup values for following parameters,

Xmx ( Maximu allowed memory)
Xms ( Startup memory).
 
Joe Ess
Bartender
Posts: 9439
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The most common cause of OutOfMemoryErrors I have observed is opening some resource, a socket, URL, file, database connection and so on, and not explicity invoking close() on it. You must invoke close in a finally block so if an exception is thrown during processing, the resource is freed.
Another less common cause in my experience is creating collections that never get cleared. Hashtables can "lose" objects if the stored object's hashcode and equals methods are improperly implemented.
You mention process creation. I haven't run into any problems with external processes, but there are streams and buffers created between the JVM and the external process, so there could concievably be a problem there. Have a read through When Runtime.exec() Won't for some common traps (i.e. not fully reading the output of the spawned process).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!