aspose file tools*
The moose likes Tomcat and the fly likes debugging memory problems in webapp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "debugging memory problems in webapp" Watch "debugging memory problems in webapp" New topic
Author

debugging memory problems in webapp

Anthony Baldarelli
Greenhorn

Joined: Feb 18, 2006
Posts: 22
Hello,
My tomcat web application seems to use a lot of memory sometimes, to the point that the RedHat Linux machine becomes unreachable. Yes, I am making some assumptions. Since I have not been able to connect to the machine when this occurs, I cannot do a "top" to confirm my theory. I just know that since the last time this occurred, the CPU usage has been reasonable, and the memory usage has been around an average of 50% per day( as an average of checking "top" every 15 minutes between 6 am and 11:45 pm ). On some busy days, it spiked to almost to 70% ( as an average for that day ).
So, based on the above assumptions, I think my webapp has some memory leaks and issues. I am trying to use netbeans to find this problem, and various profilers I have found online, but it has been an uphill battle as the tools have not worked as I would expect ( this is a separate issue ). Right now, increasing memory is not an option. So, can anyone think of any other ideas for finding memory leaks. I suppose I could scatter some calls to "java.lang.Runtime.getRuntime().freeMemory();" and "java.lang.Runtime.getRuntime().totalMemory();" and run the GC when it gets above some threshold. Just wondering if I am missing some other, better ideas.

Some version information:
1. Tomcat version: Apache Tomcat/6.0.18
2. JVM Version:
a. Production: 1.6.0_13-b03
b. Development: 1.5.0-b64
3. Linux version:
a. Production: 2.6.18-128.el5, i386
b. Development: 2.4.20-8smp, i386

Tell me if you need more information. Thanks so much.

TB
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
If this was my problem I would use the Tomcat Management App to display Thread activity and memory use as seen by the JVM.

Bill

Java Resources at www.wbrogden.com
Anthony Baldarelli
Greenhorn

Joined: Feb 18, 2006
Posts: 22
Thanks. I assume you are talking about the "manager" application that comes with Tomcat, and can be used to:
1. Stop web application
2. Check server status
3. Etc.

I am going to dig into the "server status" page. I did not catch that that page has lots of details ( I thought it was only a high level summary - oops ).
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15661
    
  15

Sometimes the Manager app "comes with Tomcat", sometimes you have to install it separately. I think it's a separate download for Tomcat6. But it's definitely helpful. Another utility that's worth firing up is the jconsole program that comes with the JDK.

Since the JVM has a lot of shared memory it can sometimes be difficult to determine which app is soaking it all up. You may also find it useful to emply the JVM's memory snapshot function to capture actual low-level memory use information.


Customer surveys are for companies who didn't pay proper attention to begin with.
Anthony Baldarelli
Greenhorn

Joined: Feb 18, 2006
Posts: 22
Yes, I have tried jconsole and visualVM, but neither can connect to tomcat JMX stuff. eventhough I have followed the directions exactly. I am going to start another thread on that issue, as it is sort of a separate issue.

Now, let me make sure we are on the same page with regards to "manager". The only I am looking it is pictured in the screenshot I attached. Is that what you mean? I clicked on "Server Status" to find some information, but it is not really that helpful.



[Thumbnail for Tomcat Manager Page.jpg]

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: debugging memory problems in webapp
 
Similar Threads
Tomcat hangs when app start-up fails
I Need a Sanity Check on this job.
Urgent!!! Need help for java API
Out of Memory with high Free Memory
Tomcat crashes with Out of Memory Error!