首页 文章

堆使用量的一半,但很多ehcache未命中

提问于
浏览
0

我们在java6 / solaris上使用hibernate3 / ehcache进行应用,并观察奇怪的堆使用模式(xmx = xms = 4G) - 从1.5G到2.5G的峰值,每5秒约为一次,如:/ | / | / | / | / |但同时我们在ehcache中观察缓存未命中几天(因此缓存很热)(通过从org.hibernate.Interceptor#onPrepareStatement钩子中记录) .

所以,问题是 - 如果在峰值之上仍有1.5G的空闲堆,如何在ehcache中发生缓存未命中?这些是ehcache SoftReference实现的一些问题吗?

GC选项:

-XX:DisableExplicitGC -XX:UseParNewGC -XX:ParallelGCThreads = 10 -XX:SurvivorRatio = 8 -XX:TargetSurvivorRatio = 50 -XX:MaxTenuringThreshold = 5 -XX:UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction = 70 -XX:UseCMSInitiatingOccupancyOnly -XX: CMSClassUnloadingEnabled -XX:CMSParallelRemarkEnabled -XX:CMSScavengeBeforeRemark -Xms4G -Xmx4G -Xmn1024m -Xss512k -XX:PermSize = 128m -XX:MaxPermSize = 256m

echache.xml(大多数实体彼此之间存在关系,并且没有很多字段):

<defaultCache 
        maxElementsInMemory="10000" 
        eternal="true" 
        overflowToDisk="false" 
        memoryStoreEvictionPolicy="LRU" 
        /> 
    <!-- Entities regions --> 
<cache name="<class>" 
       maxElementsInMemory="1500000" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" /> 

<cache name="<class>" 
       maxElementsInMemory="3000" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" /> 

<cache name="<class>" 
       maxElementsInMemory="50" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" /> 

<cache name="<class>" 
       maxElementsInMemory="50000" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" /> 

<cache name="<class>" 
       maxElementsInMemory="10" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" /> 

<cache name="<class>" 
       maxElementsInMemory="10000" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" /> 

<cache name="<class>" 
       maxElementsInMemory="1000" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" /> 

<cache name="<class>" 
       maxElementsInMemory="200000" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" /> 

<cache name="<class>" 
       maxElementsInMemory="10000" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" /> 

<cache name="<class>" 
       maxElementsInMemory="50" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" /> 

<cache name="<class>" 
       maxElementsInMemory="50" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" /> 

<cache name="<class>" 
       maxElementsInMemory="70000" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" /> 

<cache name="<class>" 
       maxElementsInMemory="50" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" /> 

<cache name="<class>" 
       maxElementsInMemory="7000" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" /> 

<cache name="<class>" 
       maxElementsInMemory="800000" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" /> 

<cache name="<class>" 
       maxElementsInMemory="10000" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" /> 

<cache name="<class>" 
       maxElementsInMemory="70000" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" /> 

<cache name="<class>" 
       maxElementsInMemory="100000" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" /> 

<!-- Collections regions --> 

<cache name="<class>.<collection>" 
       maxElementsInMemory="1500000" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" /> 

<cache name="<class>.<collection>" 
       maxElementsInMemory="200000" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" /> 

<cache name="<class>.<collection>" 
       maxElementsInMemory="500000" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" /> 

<cache name="<class>.<collection>" 
       maxElementsInMemory="10000" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" /> 

    <cache name="<class>.<collection>" 
       maxElementsInMemory="800000" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" />     

 <cache name="<class>.<collection>" 
       maxElementsInMemory="70000" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" /> 

 <cache name="<class>.<collection>" 
       maxElementsInMemory="100000" 
       eternal="true" 
       overflowToDisk="false" 
       memoryStoreEvictionPolicy="LRU" />

小号

2 回答

  • 0

    好吧,如果你将你的Ehcache限制在一定数量的内存条目(ehcache-core 2.4)或最大字节数(ehcache-core 2.5),那么他将逐出旧条目以便加入新的(即使旧的还没有过期) . 尝试将更多内容分配给最大内存限制配置,或激活溢出到磁盘选项:

    http://www.ehcache.org/documentation/user-guide/configuration

    另外,你用什么来衡量你的应用程序占用了多少内存,以及什么样的对象占用了多少内存?

    您可以在应用程序的机器上使用VisualVM本地安装,并使用nice类检测来分析对象类型的内存占用 .

  • 1

    Ehcache,如配置,将不关心可用的内存 . 它也不会在内部使用SoftReference之类的东西 . 我会监视元素是否实际被驱逐 . 如果它们是因为您达到了每个缓存设置的限制 .

    如果你期望基于大小的调整,我会使用Ehcache 2.5 . 你也在使用QueryCaching吗?

相关问题