2016-12-15 4 views
0

나는 자바 6 보스 7.1.3.AS를 사용으로 Ehcacheehcache가 얼마나 많은 메모리를 사용하고 있는지 어떻게 알 수 있습니까?

  <dependency> 
        <groupId>org.hibernate</groupId> 
        <artifactId>hibernate-ehcache</artifactId> 
        <version>5.1.0.Final</version> 
      </dependency> 

우리는 아마존 리눅스에서 실행되는이 버전의거야. ehcache가 사용하는 메모리 양을 어떻게 결정합니까? 나는 ... 위로와 함께 사용

PID USER  PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 
12159 jboss  20 0 14.9g 5.7g 25m S 163.2 19.3 225:18.15 java 

얼마나 많은 메모리를 우리의 시스템에 ...

[[email protected] ~]$ free -m 
      total  used  free  shared buffers  cached 
Mem:   30104  8099  22004   0  161  1859 
-/+ buffers/cache:  6078  24026 
Swap:   0   0   0 

을 얼마나 JBOSS에 대한 통계를 볼 수 있지만 나는 얼마나 많은 메모리 우리으로 Ehcache를 파악에 관심이 있어요 우리는 기본 캐시의 항목 수를 조정할 수 있도록 특별히 사용하고 있습니다. 프로덕션 환경에 있기 때문에 새 Java 코드를 추가하는 것은 즉각적인 옵션이 아닙니다. 당신이 힙을내어 MAT http://www.eclipse.org/mat/

으로, 예를 들어, 실행중인 자바 응용 프로그램의 힙 덤프을 받아 메모리 분석기로 분석 할 수있는 경우 다음으로 Ehcache 구성은 ...

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../config/ehcache.xsd" updateCheck="false"> 

<!-- This is a default configuration for 256Mb of cached data using the JVM's heap, but it must be adjusted 
    according to specific requirement and heap sizes --> 
<defaultCache maxElementsInMemory="200000" 
    eternal="false" 
    timeToIdleSeconds="86400" 
    timeToLiveSeconds="86400" 
    overflowToDisk="false" 
    memoryStoreEvictionPolicy="LRU"> 
</defaultCache> 
<cache name="main" maxElementsInMemory="200000" /> 

<cacheManagerPeerProviderFactory 
    class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory" 
    properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1, 
    multicastGroupPort=4446, timeToLive=32"/> 

<cacheManagerPeerListenerFactory 
    class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory" 
    properties="hostName=localhost, port=40001, 
    socketTimeoutMillis=2000"/>  

</ehcache> 

답변

0

을 수행 할 수 있습니다 덤프 jmap을 사용하십시오.

ps aux |grep java 

와 MAT와 heap_dump.hprof

jmap -dump:format=b,file=heap_dump.hprof <pid> 

파일 열기보다 예를 들어, 자바 프로세스의 PID를 확인합니다.

메모리 분석기는 개체 그래프의 도미노 트리를 제공하므로 ehcache 캐시 개체를 루트로 선택하고 자식 캐시 된 개체를 자세히 볼 수 있습니다.

+0

API는 힙 덤프를 수행하기위한 insturctions를 기입하십시오 충분히 쉽게 만들기

, 그냥 기존 캐시를 래핑합니다. – Dave

+0

@Dave 포함 – popalka

+0

그 정보 주셔서 감사합니다. 안타깝게도, "jmap"을 실행할 때 우리는 아마존 리눅스 인스턴스에서 그런 것을 발견하지 못했습니다. 힙 덤프를 얻는 다른 방법이 있습니까? – Dave

0

EhCache는 net.sf.ehcache.management.sampled.Sampled Cache을 제공합니다. JMX에 등록하십시오. 그것은 다른 것들 중에서, 등록 된 캐시에 의해 사용되는 바이트의 힙을 노출합니다.

SampledCache sampledCache = new SampledCache(cache); 

이 노출 데이터의 양이 매우 유용합니다 :

관련 문제