0

Hi have a vaadin 7 / spring 3 application which leaks memory massively.

The application is used by <500 users and needs about 30GB memory over the day. I collected multiple heap dumps and histogramms. I had some very strange observations. Since I kindof inherited this application I don't know if it is written correctly, so I can only guess.

1) After 3 hours running I have 
627 instances of MyApplication (extends UI)
420 instances of VaadinSession
but 
3296 AnnotationConfigApplicationContext

most of the Context instances are closed, but still there and have all the beans. But now the weirdest part of all. In my loadProtectedResources method (on authenticate and init) I create a new instance of of config and close them in the close() method. But my histogram show me, that I have 8134 instances of my AppConfig$$FastClassByCGLIB$$53bafb34 with further 581 classes not instances of my AppConfig with 14 instances each:

AppConfig$$EnhancerByCGLIB$$279c5c96$$FastClassByCGLIB$$40135d4c

(the number in the back changes)

and further 285 classes with one instance each:

AppConfig$$EnhancerByCGLIB$$af5a0160 

The classes that are used or imported by AppConfig are also there, so my vm contains about 20K classes which could explain where all the memory go...

In understand that those classes are created on the fly but not why they are not collected. What could I (or the previous developer) make wrong to leave the classes un-collectable in memory.

Leon
  • 1,141
  • 1
  • 10
  • 25
  • Is there a particular reason why you manually create all those spring application contexts? Would it not make more sense to have only 1 spring application context reused for all Vaadin UIs? – Morfic Apr 13 '16 at 15:41
  • I've just inherited it, but as far as I understand, all the Vaadin windows and ui elements are constructed by spring too, so every user (or session) gets its own context, with its beans and stuff. The per user context is different from the root context (which exists too) and handles DB access and stuff like that. – Leon Apr 13 '16 at 16:10
  • What JVM (vendor and version) are you using? – Nándor Előd Fekete Apr 13 '16 at 21:31
  • oracle: java version "1.7.0_80" Java(TM) SE Runtime Environment (build 1.7.0_80-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode) - we were using an older 1.7 previously, updated to latest 1.7, but it didn't change anything on this issue. – Leon Apr 14 '16 at 16:41
  • Clearly you have some misconfiguration somewhere, but you need to share lots of information including your application container configuration, web.xml (if you still have one), applicationContext.xml to find the problem. However, I recommend you to use the official [spring vaadin](https://vaadin.com/wiki/-/wiki/Main/Vaadin+Spring) and convert your project to [Spring Boot](http://start.spring.io/) as it has good error free default configuration for embedded container setup. – bekce May 04 '16 at 11:44

0 Answers0