IBM JDK 1.4를 사용하는 JVM에서 자주 발생하는 Heap fragmentation 때문에 자주 곤란한 경우가 있다.
그럼 언제 이와 같은 문제가 발생하는 것이고 원인을 뭘까 고민하던 중 아래 글과 IBM JDK diagnostic 문서를 보면 해결이 가능하다.
Java heap fragmentation의 원인들
1. 큰 객체를 할당하는 어플리케이션 (주요원인) --> 어플리케이션 수정
2. 많은 pinned, dosed 객체들 --> pCluster, kCluster 값 변경 (pinned 만 적용됨)
3. JVM fragmentation defect --> 최산 Java를 사용함
4. JNI에서 생성한 객체들 (pinned) --> JNI에서 객체를 제거해주도록 수정
5. Xms = Xmx 인 경우, 장기적으로 fragmentatino이 일어날 수 있음 --> Xms < Xmx 설정
Fragmentation is caused by the interaction between objects on the heap that can not be moved and the fact that objects need to be allocated into a single to contiguous area on the heap. These unmovable objects fall into two types:
* Pinned objects: These are object that are referenced from a location not with in the Java™ heap. Either by variables in JNI native code or by some part of the JVM's internal structure. These fall into two more sub categories; o Class objects, these are referenced from with in the native component of the classloaders and the JIT, or o Other pinned objects.
These types of objects tend to be long lived so once allocated they will stay in that location on the heap.
* Dosed objects: These are transiently pinned objects. These objects can not be moved during the current GC cycle because references to them are held on the stack of a currently executing thread. This means that they are either temporary local variables to the methods in the call stack or they are parameters that have been passed between methods with in the call stack.
When the call stack returns these objects will be free to be GC'd and/or moved in the next GC cycle assuming they are not dosed again. |
출처: http://www-1.ibm.com/support/docview.wss?uid=swg21196072
How can I prevent Java heap fragmentation?
Note that the following suggestions might not help avoid fragmentation in all cases.
o Start with a small heap. Set -Xms far lower than -Xmx. It might be appropriate to allow -Xms to default, because the default is a low value.
o Increase the maximum heap size, -Xmx.
o If the application uses JNI, make sure JNI references are properly cleared. All objects being referenced by JNI are pinned and not moved during
Pinned, Dosed 객체 목록을 보는 방법
-Dibm.dg.trc.print=st_verify,st_verbose_compact 를 사용하면 stderr로 나옴
Pinned 객체로 인한 fragmentation인지, Dosed 객체로 인한 fragmentatin인지 확인하는 방법
Pinned 객체로 인한 fragmentation일 경우, 조치 방법
st_verify 결과값을 사용해서, kCluster, pCluster 값을 조정한다.
kCluster 권장값은 class 개수 * 1.1
pCluster 권장값은 ......
원문출처 : http://blog.naver.com/bart95/70007480039
by 이환호
'1. 미들웨어이야기 > 01. JVM' 카테고리의 다른 글
JMeter를 활용한 간단한 부하테스트 (0) | 2014.12.02 |
---|---|
jar 파일에서 특정 클래스 찾기 (0) | 2014.12.02 |
jmap 명령어를 이용항 heap dump 파일 생성하기 (0) | 2014.12.02 |
jinfo 명령어를 활용한 JVM 상세 정보보기 (0) | 2014.12.02 |
jstack 명령어를 활용한 Thread dump 생성하기 (0) | 2014.12.02 |