Out of Memory Error while Parsing JPQL Query

We noticed a potential memory leak while parsing JPQL queries in 6.4.4 . In 6.2.22 everything works fine We filed a bug report here: HHH-17998 In our application we doubled the heap size and still occasionally run into OOMs. Are there any similar experiences with increased memory usage while parsing queries?

1 Like

I’m pretty sure we did not receive other reports of significantly increased memory usage, at least from version 6.2 to 6.4. The query you’re trying is huge, especially for HQL, so my immediate suggestion would be to find possible inefficiencies and try to optimize there or even think about splitting some of it up.

Since you opened an issue on our tracker and provided a reproducer someone might be able to look into it to find possible issues regarding memory usage, but Hibernate is an open source project and I cannot guarantee a fast response. The best course of action is trying to contribute yourself, you could start analyzing this through async-profile or JMC or at least provide us data (e.g. heap dumps when OOM occurs) that can help us get a general idea of what might be going on.

I have an OutOfMemoryError too because of Hibernate I think.

The problem occurs one minute after starting the program execution. From the moment the program is executed, the memory usage increases progressively until it reaches a point where the error occurs. This is strange because until a few days ago, when I ran it for the last time, it didn’t happen.

Here is my StackOverflow question:
spring boot - JPA error: OutOfMemoryError - Stack Overflow en español

Same error in 6.6.5.

org.hibernate.orm.query.hql              : HQL : select empresaEntity
from EmpresaEntity empresaEntity
where empresaEntity.ativo = ?1 and (lower(FUNCTION('unaccent', empresaEntity.nome)) like lower(concat(concat(?2,FUNCTION('unaccent', ?3)),?4)) escape '!' or lower(FUNCTION('unaccent', empresaEntity.razaoSocial)) like lower(concat(concat(?5,FUNCTION('unaccent', ?6)),?7)) escape '!' or lower(FUNCTION('unaccent', empresaEntity.cnpj)) like lower(concat(concat(?8,FUNCTION('unaccent', ?9)),?10)) escape '!' or lower(FUNCTION('unaccent', FUNCTION('regexp_replace', empresaEntity.cnpj, ?11, ?12, ?13))) like lower(concat(concat(?14,FUNCTION('unaccent', ?15)),?16)) escape '!')
order by empresaEntity.id asc
java.lang.OutOfMemoryError: Java heap space