4

I have problem with growing memory consuming on Tomcat. Just after start nothing happens,but if some user login, after this memory usage start growing in Edem. PermGen does not grow, but anyway, it anormal. jvisualvm profiling

My analyze shows that thread RMI TCP Connection produces lot of Object[] char[] and String[] objects. I can not understand what's wrong and where to dig. Who starts this thread, is is postgres connections and what is this?

ekitru
  • 162
  • 4
  • 12

2 Answers2

5

This is normal, and is NOT a memory leak. Objects are created and destroyed constantly by the threads used to manage the application. You see the memory increasing because the JVM garbage collector is not eagerly reclaiming unused memory. This happens periodically (based on previous statistics) or when memory is running low. If it were a real memory leak, you would not see the Eden memory usage drop down to almost zero after a collection. A memory leak is shown as the lowest point (right after a GC) increasing over time.

Andres Olarte
  • 4,260
  • 3
  • 21
  • 44
  • I am agree, but eden grows quite fast on local PC without any activity + on production tomcat starts to fail – ekitru Oct 31 '14 at 13:03
  • What do you mean production fails to start/ fails periodically? That seems to be a different issue, unless you're getting OutOfMemoryError or the JVM is getting stuck trying to do GC after GC. – Andres Olarte Oct 31 '14 at 13:12
  • Actually I do not get OOM exception, but on production from time to time tomcat starts to use 99% cpu load and not responsing anymore. – ekitru Oct 31 '14 at 13:16
  • 1
    When your production Tomcat stops responding, you should take a thread dump and examine that. Depending on what JVM you're using, you will also get the memory usage, which might allow you rule out a memory leak. – Andres Olarte Oct 31 '14 at 13:31
  • I just got stuck on server and got heapdump from it. BUt there is no usefull information =( The biggest one by size: char[] and String[] – ekitru Oct 31 '14 at 14:02
  • Care to post the thread dump? There's normally something useful there. – Andres Olarte Oct 31 '14 at 14:03
  • I can not publish heap dump, but Sorting by retained most popular are: HashMap, org.hibernate.persister.entity.SingleTableEntityPersister, org.hibernate.loader.Loader[] What can I find by jvisualvm? – ekitru Oct 31 '14 at 14:09
  • Yep, I can confirm this is the case. Once your application has to do something, your Eden usage will drop to zero, and used heap will drop as well. – heez Oct 18 '18 at 21:16
2

You are observing that you are observing:

The JVM gathers statistical information about itself and sends it to you. This consumes memory and uses the RMI transfer facilities.

What is RMI TCP Accept, Attach Listener, and Signal Dispatcher in Visual VM?

I also don't see a problem with what that image shows. Eden is basically always growing slowly since there is always a bit work that consumes memory.

Once Eden gets collected (~200MB worth towards the end) you can see that most of the memory is completely free and very little (~8MB) ends in the survivor spaces since there are probably still references to these objects. But they don't seem to leave survivor since OldGen is not growing, also the Histogram at the bottom shows that typical survivor objects make it to level 2 and are gone then.

This all looks pretty normal to me.

Community
  • 1
  • 1
zapl
  • 60,293
  • 10
  • 115
  • 141
  • thats right, but server do nothing, nobody connect to it and on production it failing periodically. – ekitru Oct 31 '14 at 13:02
  • 1
    Monitor for longer, the image you show is perfectly normal. If there is a memory leak, you will see OldGen (and / or maybe PermGen) growing over time. The JVM will error once OldGen is full and Garbage collection can't free enough. Also see http://stackoverflow.com/questions/542979/using-heapdumponoutofmemoryerror-parameter-for-heap-dump-for-jboss for a heapdump that should contain the actual problem. And even if your server is idle: the JVM has management tasks like a garbage collection thread that runs regardless so a bit activity is always present. – zapl Oct 31 '14 at 13:18
  • I found out PermGen OOM exception on production, great. =( – ekitru Oct 31 '14 at 13:54
  • 1
    Maybe http://stackoverflow.com/a/10248938/995891 otherwise http://frankkieviet.blogspot.ca/2006/10/classloader-leaks-dreaded-permgen-space.html – zapl Oct 31 '14 at 14:09
  • thank you, good article! I think it is not classloader memory leak, because we tried already not redeploy, but restart tomcat with stop/start. Heap shows that where is 70 mb of HashMap and arrays of HashMap. – ekitru Oct 31 '14 at 14:42