This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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...