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.
Hello All, I am seeing some behaviour which does not seem to be correct, and I wanted to check to see if anyone could verify this. When I start my app using Tomcat 4.1, I can see Tomcat.exe in the Task Manager process screen that it is using about 47,000 K of memory. As I hit the app, visiting several pages, it goes up to about 90,000 k of memory. What seems strange to me, is that when I log out of my app, and close the browser, tomcat.exe is still listed at 90,000 k of memory. Shouldn't it go backdown to the startup value of 47,000 K since I closed down my app? Thanks for any input, Kim
Shouldn't it go backdown to the startup value of 47,000 K since I closed down my app?
No - why would you expect it to? Java does not trade memory back and forth with the operating system on a short term basis. That would be very slow and inefficient, especially in a web server.
By keeping the memory under the management of the JVM Tomcat will be able to handle the next request more quickly. You didn't "close down" your app, it is still resident.
If you want to look at memory use more closely use the Manager application display to see free and total memory. Whoops - unearthing a Tomcat 4.1.30 version I see that the manager does NOT report memory use, thats an improvement in Tomcat 5. If you are stuck with Tomcat4 you can write your own servlet to show current memory usage using the Runtime freeMemory method. Bill [ December 21, 2005: Message edited by: William Brogden ]
Joined: May 17, 2001
Wow, thank you so much for your speedy reply! Still confused about one thing. After seeing the behavior documented above, I opened another browser and started hitting myapp again, and saw that the memory seemed to start growing again, using the 90k as a starting point. If the JVM had all that memory and no other browsers open, why wouldn't it use the 90k it had, and not go get more? Forgive me if this is a stupid question, I am new to learning about memory! Thanks, Kim PS, I am also trying deperatly to learn more about what is going on via the tomcat manager as you suggest. I have another posting here about that! Can't seem to see the info about threads and things that other people mention.