Hibernate Session高CPU使用率

时间:2016-12-10 07:21:08

标签: java hibernate

我一直在尝试调查我的应用,因为它正在创建大量的CPU使用率。我试图用MAT分析Heap Dump。在泄漏报告中,我找到了以下原因。

let data = [
         {name:"a", age:20},
         {name:"b", age:20},
         {name:"c", age:20}
 ]

 let filter = {name:"b"};

 //code at server --
 var filterData = data.filter(row=>{
       if(!filter){
            return true;
       }
       for(var key in filter){
           return !(row[key] !== filter[key]);
       }
      return true;
 })
 
 console.log("filterData>>>",filterData );

现在,ehcache.xml

 One instance of "org.hibernate.impl.SessionFactoryImpl" loaded by "org.apache.catalina.loader.WebappClassLoader @ 0x6c5bd5258" occupies 1,091,121,328 (38.09%) bytes. The memory is accumulated in one instance of "org.apache.commons.collections.map.AbstractHashedMap$HashEntry[]" loaded by "org.apache.catalina.loader.WebappClassLoader @ 0x6c5bd5258".

Keywords
org.hibernate.impl.SessionFactoryImpl
org.apache.commons.collections.map.AbstractHashedMap$HashEntry[]
org.apache.catalina.loader.WebappClassLoader @ 0x6c5bd5258

这里是ehcache-distributed.xml

    <defaultCache maxElementsInMemory="2000" eternal="false"
    timeToIdleSeconds="6000" timeToLiveSeconds="6000"
    overflowToDisk="false" memoryStoreEvictionPolicy="LFU">
</defaultCache>

<cache name="org.hibernate.cache.StandardQueryCache"
    maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="21600"
    timeToLiveSeconds="21600" overflowToDisk="false"
    memoryStoreEvictionPolicy="LFU">
</cache>

<!-- mandatory if you want to distribute the query cache -->
<cache name="org.hibernate.cache.UpdateTimestampsCache"
    maxElementsInMemory="400000" eternal="true" overflowToDisk="false"
    memoryStoreEvictionPolicy="LFU">
</cache>

Hibernate版本:

<defaultCache
    maxElementsInMemory="20000"
    eternal="false"
    timeToIdleSeconds="6000"
    timeToLiveSeconds="6000"
    overflowToDisk="false"
    memoryStoreEvictionPolicy="LFU">
</defaultCache>

<cache  name="org.hibernate.cache.StandardQueryCache"
    maxElementsInMemory="10000"
    eternal="false"
    timeToIdleSeconds="86400"
    timeToLiveSeconds="86400"
    overflowToDisk="false"
    memoryStoreEvictionPolicy="LFU">
    <cacheEventListenerFactory
        class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
        properties="replicateAsynchronously=true,replicatePuts=false,replicateUpdates=true,replicateUpdatesViaCopy=false,replicateRemovals=true" />
</cache>

<!-- mandatory if you want to distribute the query cache -->
<cache  name="org.hibernate.cache.UpdateTimestampsCache"
    maxElementsInMemory="400000"
    eternal="true"
    overflowToDisk="false"
    memoryStoreEvictionPolicy="LFU">
    <!-- please note the mandatory replicateUpdatesViaCopy=true -->
    <cacheEventListenerFactory
        class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
        properties="replicateAsynchronously=true,replicatePuts=true,replicateUpdates=true,replicateUpdatesViaCopy=true,replicateRemovals=true" />
</cache>

你能帮我理解这些设置吗?这是最佳做法还是有任何错误的配置?

0 个答案:

没有答案