L
L
luckyduck12017-02-08 20:57:11
Java
luckyduck1, 2017-02-08 20:57:11

How to fix Spring (MVC, Security) + Hibernate + Tomcat memory leak?

There is an application on Sprimg (MVC, Security) + Hibernate, I run it on Tomcat. The application has about 50 tables in the database, 80 models, etc. (this number is apparently due to a misunderstanding of the implementation of relationships between tables)
If you suddenly need it, the code: https://github.com/StepanovNickolay/myCRM
Memory leaks occur when starting:

  • If you start the application and leave it untouched, then the memory used slowly increases from 150MB to 650MB, then the GC seems to work and the memory becomes 100MB again. Here's what it looks like in VisualVM:
    1a7eaeb5cd34400898d5afa2b268b38c.png
  • If, after launch, you actively navigate through all the tabs and use the application very actively, then the same thing happens, only much faster.

How can this be fixed?
+ another question:
I will upload the application to the hosting and it will be used by 10-20 people. You need to choose a tariff and calculate the amount of memory. If now I alone spend 150-650MB, does this mean that 3 people will spend 3 times more?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2017-02-09
@dsv

Are you sure it's a leak? It seems that even in the idle state, the application is constantly processing something, creating objects, which it then does not use. These unused objects are removed by the collector. Otherwise, you would have grown the minimum amount of memory after the work of the collector.
Observe the objects on the heap, determine which objects are removed after a large amount of garbage collection, and find the place in the code where they are created. And then think about it, maybe you don’t need to create them all the time.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question