Java Hibernate会话CPU使用率高

Java Hibernate会话CPU使用率高,java,hibernate,Java,Hibernate,我一直在尝试调查我的应用程序,因为它造成了大量的cpu使用。我试图用MAT分析堆转储。在泄漏报告中,我发现了以下原因 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 accumulate

我一直在尝试调查我的应用程序,因为它造成了大量的cpu使用。我试图用MAT分析堆转储。在泄漏报告中,我发现了以下原因

 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.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>

这里是ehcache-distributed.xml

<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>

休眠版本:

<hibernate.version>3.5.5-Final</hibernate.version>
<hibernate-validator.version>4.2.0.Final</hibernate-validator.version>
3.5.5-最终版本
4.2.0.4最终版本

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

因此,您有一个CPU使用问题,要找到它的来源,您需要查看内存包含什么?如果你有内存使用问题,我会理解的。但内存中的东西不会消耗任何CPU。当我试图调查时,我发现GC导致了大量CPU使用。S0和S1显示为零,旧空间在几秒钟内变为100%。几乎每秒都会导致FGC。那么,这和我所做的不相关吗@JBNizetSo,您有一个CPU使用问题,要找到它的来源,您需要查看内存包含什么?如果你有内存使用问题,我会理解的。但内存中的东西不会消耗任何CPU。当我试图调查时,我发现GC导致了大量CPU使用。S0和S1显示为零,旧空间在几秒钟内变为100%。几乎每秒都会导致FGC。那么,这和我所做的不相关吗@JBNizet