Is possible to use LRU cache for QueryPlanCache

We are using hibernate in docker with small heap memory. after dump the memory from JVM, we found there are 600+ instances in the memory, and cost 38M memory. the default cache size is 2048, the memory may grow to 150M+. We want limit it, but after i search the codes, the QueryPlanCache use just use BoundedConcurrentHashMap to cache it.

Is any possible to use LRU cache for it?

What instances are you talking about?

the default cache size is 2048, the memory may grow to 150M+

That’s for the entity plan cache. Are you having so many queries that the plan cache can grow to 150M?

We want limit it, but after i search the codes, the QueryPlanCache use just use BoundedConcurrentHashMap to cache it.

It’s already limited. That’s why it uses a bounded Map.

Is any possible to use LRU cache for it?

The BoundedConcurrentHashMap supports a LRU policy, but it’s not configurable. Why to you think it’s better than the default LIRS policy?