I have a spring boot application that used spring data. I have native queries and query methods. Apparently i'm facing a memory issue from my application. I tried doing jmap -histo to determine the class that uses a lot of resource.
On my first jmap dump this is the result (first day) -fresh start
Then on the second day this is the result
Notice the org.hibernate.hql.internal.ast.tree.Node starts to appear.
Then on the third day
The org.hibernate.hql.internal.ast.tree.Node is increasing in memory size.
Hope you can help me, or any suggestion? I haven't posted the code since I haven't isolated the one causing this. Btw, there are no operations during the night so i'm expecting garbage collection should run.
Apparently, hibernate is caching all of its queries this is so that hibernate will not recompile prepared statement however if you have a dynamic query it will result to memory overflow.
Ex:
Prepared Statement
Select * from employee where id = :id
-> this is okay since hibernate will just cache the prepared statement but if you do something like this
select * from employee where id = 1
select * from employee where id = 2
select * from employee where id = 3
-> Hibernate will cache that 3 statement hence the memory overflow.