miércoles, 22 agosto 2007

java.lang.OutOfMemoryError: PermGen space // More memory for Tomcat under windows

« Updated: Displaying a jTable inside another jTable // JTable cellRenderer | Main | Viewing and storing images from an IP Camera »

In many cases, web applications give OutOfMemoryError when their threads require high levels of  memory. Image manipulation or intensive database use or calculation can lead to this very common problem.

Normally when you get an OutOfMemory error in a desktop application, you can solve this problem by specifying the java commands -Xms*** (initial Java heap size) and -Xmx*** (maximum Java heap size) when running your program.

To solve this issue in tomcat, you must specify these options in the tomcat startup command / script / batch. In windows tomcat is installed as a service. Tomcat provides a configuration tool to set up these and other parameters. you can find it in (Start->Programs->Apache Tomcat->Configure Tomcat) or by running (.\bin\tomcat5w.exe" //EN//Tomcat5).

Tomcat Properties

Under the "Java" tab you can find two options:

  • Initial memory pool: This corresponds to -Xms, you can specify the size in Mb.
  • Maximum memory pool: This corresponds to -Xmx, you can specify the size in Mb.

Now you can specify a higher maximum memory so that Tomcat doesn't get the OutOfMemoryError. Remember to take in consideration your hardware capabilities.

Technorati Tags:

Posted by admin at 3:55 PM in Apache Tomcat

 

[Trackback URL for this entry]

Comment: None at vie, 31 oct 12:08 PM

Cool site.

Comment: c0d at vie, 3 abr 1:29 PM

Actually your suggestion is pretty wrong when talking PermGen or ThreadStack sizes. Changing values for the size of heap will have zero effect on the thread stack size or the perm gen (where code is loaded) size.

1.Xms and Xmx specify the size of HEAP.
2. Xss specify the thread stack size and hardware platform dependent and you should not change unsless you really know what are you talking about
3. to change the size of PermGen you need to use another parameter: -XX:MaxPermSize=128m (replace 128m with your value) default I think it is 64m but not sure

Your comment:

(not displayed)
 

SCode

Please enter the code as seen in the image above to post your comment.

 
 

Live Comment Preview:

 
Google
 
« August »
SunMonTueWedThuFriSat
   1234
567891011
12131415161718
19202122232425
262728293031