Jdban101
Jdban101

Reputation: 377

How can I find out why Tomcat is using so much memory and stop it?

I'm profiling my webapp using YourKit Java Profiler. The webapp is running on tomcat 7 v30, and I can see that the heap of the JVM is ~30 megabytes, but Tomcat.exe is using 200 megabytes and keeps rising keeps rising.

Screenshot: https://i.sstatic.net/xYovn.png (On left is how much memory profiler says Java is using, on right is Windows usage of tomcat.exe)

I've tried adding different flags to tomcat, but still the memory usage keeps rising and rising. I've tried precompiling my .jsp files as well in case that helps, but it hasn't.

The flags I've added to tomcat's java flags:

-XX:+UseG1GC
-XX:MinHeapFreeRatio=10
-XX:MaxHeapFreeRatio=10
-XX:GCTimeRatio=1

Tomcat is also running as a windows service if that matters at all.

I need assistance figuring out how to get tomcat to use less memory/know why it's using so much memory. As is is now, it keeps going until it uses the whole system's memory.

Upvotes: 0

Views: 10181

Answers (3)

Jdban101
Jdban101

Reputation: 377

So the solution that I found was to add some flags to the tomcat run.

Not sure which flag it was. I think it might've been the jacob library we were using, or some combo of these flags with that. Hopefully this can help people in the future.

-XX:+UseG1GC
-XX:MinHeapFreeRatio=10
-XX:MaxHeapFreeRatio=10
-XX:GCTimeRatio=1
-Dcom.jacob.autogc=true
-Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true

Upvotes: 2

maslan
maslan

Reputation: 2178

You could dump Yor memory and see what is using it. Propably it will be a long list of Your application objects, or strings You unknowingly internalize.

You might use a tool like jvisualvm, or a cool eclipse tool: http://www.eclipse.org/mat/ to do that.

If You do that and still dont know why, then post us what objects are in Your memory....

Upvotes: 0

akm
akm

Reputation: 34

You should look for memory leaks in your application, or large sessions that live too long and not invalidated. Try to think which functionality holds too many objects for long periods.

Upvotes: 1

Related Questions