简体   繁体   中英

Allocating memory for first level cache per a session

When some of sessions fetch many entities, these entities are stored in the first-level cache and this can lead to out of memory problems and server crash.

This may happen for many different reasons, like a developer writing a bug in his query, or allowing setting of incorrect parameters on the screen.

The problem I intend to target is NOT to resolve the problem on a single application level, but rather to prevent the server crash. It is perfectly fine if the application operation will fail.

Is there a way to prevent Hibernate from allocating entities per a session after reaching some maximum?

You could maybe try to use a Hibernate Interceptor to maintain a counter per session and throw an exception if it exceeds a threshold, but there is no builtin way of doing what you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM