On Fri, 3 Jan 2003, Julian L�ffelhardt wrote:
> Date: Fri, 3 Jan 2003 02:01:58 +0100 > From: Julian L�ffelhardt <[EMAIL PROTECTED]> > Reply-To: Tomcat Users List <[EMAIL PROTECTED]> > To: Tomcat Users List <[EMAIL PROTECTED]> > Subject: Re: Memory Usage and Garbage Collection > > Looking at the jasper source of tomcat 4.0.4 releasing jsp's seems to be > reasonable easy to implement: > The Jsp's classloader, the class and the actual jsp-servlet instance are > all put together in a JspServletWrapper-Object which itself is stored in the > JspServlet (the Servlet used to executing jsps) using a Hashtable. > One could replace the hashtable with a LRU-Cache or anything. > > Since each jsp is loaded using a separate classloader, removing the Wrapper > removes the reference to the instance, it's class and it's loader, which > should enable the class garbage collector to remove the class. > > Do you think this approach is reasonable? > Does this part of the implementation differ with Jasper2? > You'd best examine the sources to figure that out :-). But Jasper2 is radically different than Jasper1. But remember, it's not just a matter of throwing away the reference to the compiled servlet class. You also need to ensure that the destroy() method gets called as the servlet API requires -- all the while ensuring that no additional requests start getting processed through the service method. And, don't forget that this will harm performance for the vast majority of users who *do* have adequate memory on their servers, so nothing like this should be enabled by default. > This is a feature I could really use well. > > llap, > julian Craig > > ----- Original Message ----- > From: "Craig R. McClanahan" <[EMAIL PROTECTED]> > To: "Tomcat Users List" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > Sent: Friday, January 03, 2003 1:12 AM > Subject: Re: Memory Usage and Garbage Collection > > > > > > > > On Thu, 2 Jan 2003, Brandon Cruz wrote: > > > > > Date: Thu, 2 Jan 2003 16:16:23 -0600 > > > From: Brandon Cruz <[EMAIL PROTECTED]> > > > Reply-To: Tomcat Users List <[EMAIL PROTECTED]>, > > > [EMAIL PROTECTED] > > > To: Tomcat Users List <[EMAIL PROTECTED]> > > > Subject: Memory Usage and Garbage Collection > > > > > > Do loaded jsp pages and/or class files ever get garbage collected when > > > tomcat is running? > > > > > > > It's legal for servlet containers to destroy and release servlets and JSP > > pages while the server is running, but Tomcat doesn't currently do so. > > Once a servlet or JSP is loaded, it stays loaded until you reload that > > particular webapp or you shut Tomcat down. > > > > > We have a production server with several hundred virtual hosts per host, > > > each with a fair share of jsp pages and with moderate to low traffic per > > > host. As time goes on, the amount of memory being used constantly > grows. > > > It starts off around 60MB, then goes higher and higher, getting up to > around > > > 100MB after a couple days. > > > > > > The regular GC seems to usually clean up around 2MB ([GC > > > 99493K->97502K(204544K), 0.0243521 secs]) and the Full GC seems to clean > up > > > less than that ([Full GC 97388K->97187K(204544K), 2.4269915 secs]). > > > > > > Since I have the -Xmx and -Xms set to 200MB, the 204544K number never > gets > > > resized, but the number before the -> seems to slowly and steadily rise. > > > > > > Full GC seems to run quite often, every few seconds, GC runs once in a > > > while, but spits out about 50 lines at once every time it runs. Is this > > > normal? Shouldn't Full GC only run once in a while? > > > > > > I am starting to think that as classes and jsp's are loaded, they stay > in > > > memory and are never released until tomcat is restarted, which means > that > > > there is eventually a point where all the classes will load and I just > need > > > to have enough memory to support that without having to use swap space. > > > > > > > It's not just the classes -- it's the object instances created from those > > classes that take up space (the bytecodes of the class itself exist only > > once). > > > > > The problem occurs when the memory usage number before the -> gets up to > > > about 130. The system is using swap space and eventually out of memory > > > errors start showing up. > > > > > > Any ideas? More Ram, more tuning, different site architecture? > > > > > > > If you're using swap space, you probably have your max heap size (-Xmx) > > too large for the amount of physical memory that is available. I'd > > definitely start by either reducing -Xmx or increasing the amount of > > physical RAM. If reducing -Xmx gives you OutOfMemoryException errors, > > then increasing RAM is the only option. > > > > The second thing I'd do is review my applications for places where they > > might be maintaining references to data in between requests, either in > > instance variables of the servlet or JSP class or by keeping too many > > things in the user's session for too long. If there are such references, > > your user data objects cannot be GC'd and you'll end up with exactly the > > pattern you describe (slowly increasing memory use). > > > > > Thanks in advance? > > > > > > Brandon > > > > Craig > > > > > > -- > > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > > > > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
