3

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

first

Then on the second day this is the result

second

Notice the org.hibernate.hql.internal.ast.tree.Node starts to appear.

Then on the third day third

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.

Clark
  • 143
  • 1
  • 9

3 Answers3

1

I also encountered the same problem. The following configuration may help.

spring:
  jpa:
    properties:
      hibernate:
        query:
          plan_cache_max_size: 64
          plan_parameter_metadata_max_size: 32
Jianchen Ding
  • 111
  • 1
  • 7
0

I can't answer what was causing this. However, updating the version of Spring Boot (which in turn updated the Hibernate version) to 2.2.1.RELEASE appeared to resolve these issues for me.

bmarcj
  • 51
  • 2
  • 6
0

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.

Clark
  • 143
  • 1
  • 9