Minimize RAM usage

In start my application with hibernate using 300-400 mb ram. But then usage of RAM increases and does not decrease until it takes up the entire free RAM.

I tried to do

EntityManager#flush();
EntityManager#clear();

EntityManagerFactory#getCache().evictAll()

But it does not helped me. How can I decrease a RAM usage?

You need to run a memory profiler and get a detailed report of Heap memory usage.

Afterwards, you can post it here do we can see which Hibernate class is causing the issue.

Typically, you can use VisualVM which is bundled with the JDK to do that.

The binary is jvisualvm.

1 Like