views:

21

answers:

1

I have heard a few people say that deploying a portlet war file (or perhaps any war) that includes a lot of large jars can cause performace issues because all those jars get loaded into memory. If you have several wars, all of which include a ton of large jar files, your system will get bogged down.

I'm trying to get my head around why this is true - and I haven't found anything that explains it in a way that I get it. Maybe I'm searching for the wrong terms which is why I'm not finding much information. Can anyone explain what exactly is happening when a portlet gets instantiated and if indeed those jars start taking up memory?

+1  A: 

The short response is: yes, deploying a war file with a lot of jars "could" cause performance issue. It does not matter if the war contains a portlet or a standard web application. But in my opinion you should not worry about this prematurely, because there are easy solutions for this problem.

When a portlet or any webApp is loaded into the server it loads the classes of the main jar into the "Permanent generation" region of the heap (memory assigned to the Java process) of the web server. This region stores the code that is executed. When these classes use code from other jars, their code is also loaded into this region. If this regions is filled up, you will get an OutOfMemoryError exception.

The solutions for your problems are easy:

  1. Dedicate more memory to your memory (parameter -Xmx of the JVM)

  2. If you have several .war files with the same jar files in them, remove those jars from the war files and put them in the directory where all the common libraries of the Web Server are located. The location of this directory depends on the Web App server that you are using.

So, you should not worry about this problem because it has a solution.

This PDF http://java.sun.com/j2se/reference/whitepapers/memorymanagement_whitepaper.pdf explains how memory management works in Java. It applies to regular Java apps and Web applications.

Rambaldi
Thank you - now I get it!
Michaela