Java Heap & GC Tuning

Tips 2008. 8. 25. 17:21

서버의 경우 -server 옵션을 주고,

Heap의 크기를 다음 옵션으로 증가시킨다.

-Xmx512m -Xms512m

최대 Heap 크기와 최소 Heap 크기를 동일하게 함으로써,

resizing에 따른 오버헤드를 피할 수 있다.

Heap 크기가 너무 작으면 GC가 빈번하게 발생한다.

이는 GC의 CPU 점유율이 증가시켜 성능 저하를 야기시킨다.

Heap 크기가 너무 크면 OS에서 가상 메모리를 할당한다.

이는 할당된 메모리가 swap in/out함으로써 성능 저하를 야기시킨다.

적당한 Heap 크기를 결정하는 것이 중요하다.

그 외에 세부적인 튜닝은 다음 문서들을 참고하자.

http://polly97.wordpress.com/2006/08/10/jvm-gc%EC%99%80-%EB%A9%94%EB%AA%A8%EB%A6%AC-%ED%8A%9C%EB%8B%9D/
http://fedora.fiz-karlsruhe.de/docs/Wiki.jsp?page=Java%20Heap%20%26%20GC%20Tuning
Posted by 알 수 없는 사용자
,

-server 옵션으로 JVM 실행 시 다음과 같은 에러에 직면할 수 있다.

Error: no `server' JVM at `C:\Program Files\Java\jre1.6.0_07\bin\server\jvm.dll'.

JDK의 JRE에 포함되어 있는 server 버전 JRE에 복사한다.

Reference:
http://thiamteck.blogspot.com/2007/10/error-no-server-jvm-at.html

Posted by 알 수 없는 사용자
,

visualgc

Tips 2008. 8. 25. 14:09

Graph Window
The Graph window displays plots the values of various statistics as a function of time. The resolution of the horizontal axis of the graph is determined by the interval command line argument, where each sample occupies 2 pixels of screen area. The height of each display depends on the metric being plotted.
The following displays are provided

Compile Time
This panel plots the amount of time spent compiling Java byte codes into native code. The height of this display is not scaled to any particular value. A non zero value in this graph indicates that compilation activity occurred during the last interval. A narrow pulse indicates a relatively short duration and a wide pulse indicates a long duration. The title bar indicates the number of compilation tasks and the accumulated compilation time since the start of the application.

Class Loader Time
This panel plots the amount of time spent in class loading and unloading activities. The height of this display is not scaled to a particular value. A non zero value in this graph indicates that class loading activity occurred during the last interval. A narrow pulse indicates a relatively short duration and a wide pulse indicates a long duration. The title bar indicates the number of classes loaded and unloaded and the accumulated class loading time since the start of the application.

GC Time
This panel plots the amount of time spent in garbage collection activities. The height of this display is not scaled to any particular value. A non zero value in this graph indicates that garbage collection activity occurred during the last interval. A narrow pulse indicates a relatively short duration and a wide pulse indicates a long duration. The title bar indicates the total number of GC events and the accumulated GC time since the start of the application.

If the target JVM maintains the hotspot.gc.cause and hotspot.gc.last_cause counters, the cause of the GC events will also be displayed in the title bar for this graph.

Eden Space
This panel plots the utilization of the Eden Space over time. The Eden Space is one of three spaces that make up the Young Generation. The height of this panel is fixed and, by default, the data is scaled according to the current capacity of the space. Since the current capacity of the space can change dynamically depending on the collector policy, visual artifacts may occur as the space shrinks and grows over time.

The title bar displays the name of the space and its maximum and current capacity in parenthesis followed by the current utilization of the space. In addition, the title also contains the number and accumulated time of Young GC events.

Survivor 0 and Survivor 1
The Survivor panels plot the utilization of the two survivor spaces over time. The Survivor Spaces are the remaining two spaces comprising the Young Generation. The height of each of these panels is fixed and, by default, the data is scaled according to the current capacity of the corresponding space. Since the current capacity of the survivor spaces can change dynamically depending on the collector policy, visual artifacts may occur as the space shrinks and grows over time.

The title bar displays the name of the space and its maximum and current capacity in parenthesis followed by the current utilization of the space.

Old Gen
The Old Gen panel plots the utilization of the Old Generation over time. The Old Generation is comprised of a single space. The height of the panel is fixed and, by default, the data is scaled according to the current capacity of the space. Since the current capacity of the space can change dynamically depending on the collector policy, visual artifacts may occur as the space shrinks and grows over time.

The title bar displays the name of the space and its maximum and current capacity in parenthesis followed by the current utilization of the space. In addition, the title also contains the number and accumulated time of Full GC events.

Perm Gen
The Perm Gen panel plots the utilization of the Permanent Generation over time. The Permanent Generation is comprised of a single space, but does not have its own collector. Instead, this space is collected as part of the Old Generation. The height of the panel is fixed and, by default, the data is scaled according to the current capacity of the space. Since the current capacity of the space can change dynamically depending on the collector policy, visual artifacts may occur as the space shrinks and grows over time.

The title bar displays the name of the space and its maximum and current capacity in parenthesis followed by the current utilization of the space.

Each of the GC space graphs can be displayed in one of two modes - reserved mode or committed mode, with committed mode being the default. In reserved mode, the data is scaled according to the maximum capacity of the space while in committed mode, the data is scaled according to the current capacity of the space. In reserved mode, the background grid is painted in dark gray to represent that portion of the reserved memory that is uncommitted memory and in green to represent the portion that is committed. The mode can be toggled by right-clicking over the space and checking or un-checking the "Show Reserved Space" check box.

Reference:
http://java.sun.com/performance/jvmstat/visualgc.html

Posted by 알 수 없는 사용자
,