This annoying error of PermGen space OOMs when reloading the webapp in tomact is because in tomcat the class loader only loads the classes and this class loader and loaded classes are never garbage collected. Each time you reload your webapp, copies of classes will be added to memory, basically the permanent heap space used by tomcat. This eventually makes tomcat run out of memory to further carry out operation.
This is common and can happen with other containers also until unless in some version the owner have made changes to take care of this. Try reloading the application again and again until unless your container cry of Out of Memory Error. What we can do in such a situation is to restart the container which basically clean up the heap and load the application again.
Additionally try no putting your JDBC and commons jar in the WEB-INF. Instead you can put them in the TOMCAT-HOME/common/lib folder because these are already bootstrapped by tomcat. If you face issue of 'No suitable driver' Exception after placing your jdbc jar in tomcat common/lib, try adding you jndi db definition in context.xml like
<\Context path="/test" reloadable="true" debug="1">
<\Resource name="jdbc/db" auth="Container" type="javax.sql.DataSource" maxActive="30" maxIdle="3"
maxWait="10000" username="testing" password="testing" driverClassName="net.sourceforge.jtds.jdbc.Driver" url="jdbc:testdburl;lastupdatecount=true" />
Is there any upgrade in Tomcat 6.0 for reloading application and still avoiding OOMs?
ReplyDelete