Heap Memory 가 충분한데도 GC 가 빈번하게 일어나고 있고

또 비교적 큰 객체를 생성할 때 빈번히 Allocation Failure 가 발생할 경우

-Xloratio 옵션을 적용하면 도움이 될 것 같습니다.

 

 

## GC 로그에서 다음과 같은 내용을 볼 수 있습니다.
....

  <AF[141]: Allocation Failure. need 5865496 bytes, 92 ms since last AF >
  <AF[141]: managing allocation failure, action=2 (887107216/1073740288)>

....

## 테스트를 해보면, -Xloratio 옵션을 준 경우에는 GC로그에도 새로운 내용이 추가됩니다.


 1) 일반적으로 Heap 메모리만 설정한 경우
 전체 Java Heap 메모리와 free Heap 메모리만 나옵니다.
....

 <GC(1): freed 269696 bytes, 98% free (66059528/67041792), in 14 ms>
 <GC(1): mark: 7 ms, sweep: 1 ms, compact: 6 ms>
 <GC(1): refs: soft 0 (age >= 32), weak 0, final 1, phantom 0>
 <GC(1): moved 4571 objects, 489408 bytes, reason=4>

....

 2) -Xloratio 옵션 적용한 경우
 전체 Java Heap 메모리와 free Heap 메모리이외에 LOA영역이 별도로 나옵니다.
....

 <GC(1): heap layout: (52651168/53633432) (13408360/13408360) /0>    <== LOA 영역 별도 표시
 <GC(1): freed 269696 bytes, 98% free (66059528/67041792), in 14 ms>
 <GC(1): mark: 6 ms, sweep: 2 ms, compact: 6 ms>
 <GC(1): refs: soft 0 (age >= 32), weak 0, final 1, phantom 0>
 <GC(1): moved 4571 objects, 489408 bytes, reason=4>

....