当Ehcache用于休眠二级缓存时的垃圾收集 [英] Garbage collection when Ehcache is used for hibernate second level cache

查看:132
本文介绍了当Ehcache用于休眠二级缓存时的垃圾收集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当Ehcache用于hibernate二级缓存时,echache中的对象是否被JVM收集垃圾?

他们最终会收集垃圾......



但是,如果你说ehcache中的对象,我会试着说......取决于它。即只要Ehcache认为数据有价值,并且只配置了堆内存储,它就会保持堆状态。根据您运行的版本和缓存的拓扑结构,当不再认为足够热以保持堆上(即尽可能接近您的应用程序的代码)时,ehcache会将条目发送到另一个层(offheap,disk)或者仅仅处理它(虽然它也可能已经存在于其他地方:offheap,disk,TSA;并且因此通过Cache的API保持可用,而不再是堆上),使其有资格进行GC_ing。

When Ehcache is used for hibernate second level cache, do the objects in echache get garbage collected by the JVM?

解决方案

They will eventually get garbage collected...

But given you say "the objects in ehcache", I'd be tempted to say... it depends. i.e. for as long as Ehcache deems the data "valuable" and you only have on-heap storage configured, it'll remain on heap. Depending on the version you run and the cache's topology, when not considered "hot" enough anymore to remain on-heap (i.e. as close as possible to your application's code), ehcache will either send the entry to another tier (offheap, disk) or just dispose of it (while it could also already be present elsewhere: offheap, disk, TSA; and as such remain available through the Cache's API, while not being on-heap anymore), making it eligible for GC'ing.

这篇关于当Ehcache用于休眠二级缓存时的垃圾收集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆