File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes memory not GC'd after hours of sitting idle? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "memory not GC Watch "memory not GC New topic

memory not GC'd after hours of sitting idle?

Stephen Huey
Ranch Hand

Joined: Jul 15, 2003
Posts: 618
We have a couple of web servers running Tomcat 4.1.27 with j2sdk1.4.2_06, and on a little admin page, we print out the amount of total memory for the JVM and the amount of free memory. At the moment, I have the -Xmx and -Xms flags set to 768m (3/4 of a GB is what I'm going for), so the total is printing out at 799145984 bytes.

I used JMeter to run 200 threads against one of the app servers and it took several minutes to get the free memory down to 100 MB, and then about the same amount of time to push it under 50 MB. After sitting idle for about 6 hours, the sessions have all timed out and the free memory has climbed back up to 389221912 bytes. Why isn't it even higher than this? Most of the big stuff is stored in user sessions, and there aren't many global objects at all. Is the GC just not feeling pressure to do anything?

I didn't do much of anything with the other app server...just logged into a couple of users' sessions, and then parked a web browser on that admin page. Its total memory allocation is also 768 MB, but for some reason it now has only 86183104 bytes free! Another 3 minutes later, and I click refresh on the page and it's down to 77470448...all I or anyone else is doing is refreshing this one fairly simple page! It seems to go down every time I refresh the page. Isn't this bad? What do I check for? A couple of database reads are performed to display info on the page, but the number of open db connections in the pool isn't going up, so I don't think there's a leak there...

Jessica Sant

Joined: Oct 17, 2001
Posts: 4313

I'm thinking this might be a Tomcat-specific issue?? So I'm going to move it to that forum, hopefully you'll get some good insight there.
I agree. Here's the link:
subject: memory not GC'd after hours of sitting idle?
It's not a secret anymore!