0

I have a webapp that combines Spring + Hibernate. I deploy this locally in a Tomcat Server and I get memory consumptions of around 150-200 Mb which to my knowledge is not that high at all. But apparently in production deployment, which works over WebSphere, I am getting 500Mb of memory usage, and a very high frequency of garbage collection.

At first I blamed Hibernate for the problem (as seen in this other question) but now I am lost as to what might be causing this apparent high usage.

I tried profiling my app using MAT and these are my histogram results:

Histogram Dominator tree

I haven't got much experience at profiling memory and most of the time I feel as if I was looking at the car's engine after a failure, but it seems to me that the char[] references are related to spring's internal "database" of beans. I use annotation based configuration for spring's mvc components and transactions:

<tx:annotation-driven />
<context:annotation-config />

Do you find any of these values to be exceptionally high? Can you help me tracing the problem up?

PS. this is my dominator for a heap dump nearer to a full heap enter image description here

9
  • Those numbers don't look too high to me, e.g. if 4.5 MB retained heap are 18.41% of the entire heap, you only use 25 MB heap. That doesn't look much to me. Are you sure you analyzed the correct dump? You should make one when the heap is almost full (or on OutOfMemoryError) and analyze that. Commented Feb 3, 2014 at 9:13
  • (a) That is not a programming question. (b) Unless your production environment is exactly the same as your local environment, you shouldn't expect the memory usage to be the same. Are you actually seeing a problem? Garbage collection is a normal thing, and is not indicative of a memory leak. Commented Feb 3, 2014 at 9:15
  • @TedBigham it's a normal thing, but not if it happens too often. Maybe memory leak is not the right way to call it, maybe i should have said "high memory consumption" Commented Feb 3, 2014 at 9:18
  • @kelmer, a memory leak is memory that will NEVER be garbage collected. So the garbage collector running a lot, is almost the exact opposite of a memory leak. Commented Feb 3, 2014 at 9:19
  • @Thomas I posted another picture with a dominator tree of a dump nearer to a full heap Commented Feb 3, 2014 at 9:19

3 Answers 3

2

Both your problems are (usually) normal.

The garbage collector running often indicates you have a lot of processing going on, especially the kind that creates lots of objects (like jdbc). Unless your server becomes non-responsive during garbage collection, it's nothing to worry about. If it's not returning to the baseline memory (the bottom of the sawtooth memory graph) after garbage collection, you might have a leak.

High memory usage is also normal, especially if you've given more memory to the production JVM than your local one. Compare your startup parameters and make sure they are the same before trying to compare their performance results.

[i know this is not really an answer, but it's too long to fit in comments]

Sign up to request clarification or add additional context in comments.

Comments

1

You do realise that (unless you're using Liberty Profile) WebSphere piles a huge number of additional jar files into your classpath compared to Tomcat? Therefore, a significantly larger memory footprint is absolutely to be expected under WebSphere.

Excessive garbage collection implies that you have not allocated enough memory to your application JVM. Give it significantly more (2 gig for instance) and watch the runtime memory usage graph via JConsole or a similar tool. Watch what memory consumption it reaches before a more relaxed garbage collection and use that to educate yourself on how much the JVM does really need.

Note that if after each garbage collection, the graph does not return to a safe baseline, but instead only reduces partially, then you probably have a memory leak.

Comments

0

I have found that I do have a high memory consumption for each rendered page, and have pinpointed the issue to Apache Tiles. If I use Tiles, each page load burdens the heap with up to 30 mb of memory usage, which does feel like a lot. Disabling it causes almost no memory consumption.

Debugging the controller methods shows that within the method itself almost no memory consumption is done, but it is upon returning control to the viewresolver (i.e. after the controller method ends) when the 30mb memory usage fires.

The problem now is, how to reduce this memory usage??

1 Comment

is it normal that all my resources (even static ones such as images, scripts...) are boing processed by FrameworkServlet?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.