사용자 도구

사이트 도구


java:options

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
java:options [2017/08/08 08:52]
kwon37xi
java:options [2021/08/02 16:31] (현재)
kwon37xi
줄 1: 줄 1:
 ====== Oracle(SUN) JVM Options ====== ====== Oracle(SUN) JVM Options ======
   * JVM 기본 옵션 출력<code sh>   * JVM 기본 옵션 출력<code sh>
 +java -XX:+PrintCommandLineFlags -version
 +// or
 java -XX:+PrintCommandLineFlags -version java -XX:+PrintCommandLineFlags -version
 </code> </code>
 +    * 메모리 관련 항목은 ''HeapSize'', ''PermSize'', ''ThreadStackSize''로 볼 수 있다. byte 단위.
   * [[http://docs.oracle.com/javase/6/docs/technotes/tools/windows/java.html|Java 6 Options]]   * [[http://docs.oracle.com/javase/6/docs/technotes/tools/windows/java.html|Java 6 Options]]
 +  * [[https://javaworks.wordpress.com/2013/06/25/jvm-parameters-you-should-know/|JVM parameters You should Know]]
   * [[http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html|JVM Options]]   * [[http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html|JVM Options]]
   * ''-verbose:class'' : 어떠한 클래스를 적재하는지 확인해 볼 수 있다. [[http://ntalbs.tistory.com/143|NoSuchMethodError 참조]]   * ''-verbose:class'' : 어떠한 클래스를 적재하는지 확인해 볼 수 있다. [[http://ntalbs.tistory.com/143|NoSuchMethodError 참조]]
줄 21: 줄 25:
 ===== -XX:-OmitStackTraceInFastThrow ===== ===== -XX:-OmitStackTraceInFastThrow =====
   * Oracle JVM 에서 예외가 발생하여 로그로 남겼는데, 로그에 스택 트레이스가 안 찍히는 현상이 발생할 수 있다. (exception, stacktrace, missing)   * Oracle JVM 에서 예외가 발생하여 로그로 남겼는데, 로그에 스택 트레이스가 안 찍히는 현상이 발생할 수 있다. (exception, stacktrace, missing)
 +  * [[http://jawspeak.com/2010/05/26/hotspot-caused-exceptions-to-lose-their-stack-traces-in-production-and-the-fix/|Hotspot caused exceptions to lose their stack traces in production – and the fix at JAW Speak]]
   * [[http://www.oracle.com/technetwork/java/javase/relnotes-139183.html|Java 5 Release Notes]]   * [[http://www.oracle.com/technetwork/java/javase/relnotes-139183.html|Java 5 Release Notes]]
  
-> The compiler in the server VM now provides correct stack backtraces for all "cold" built-in exceptions. For performance purposes, when such an exception is thrown a few times, the method may be recompiled. After recompilation, the compiler may choose a faster tactic using preallocated exceptions that do not provide a stack trace. To disable completely the use of preallocated exceptions, use this new flag: -XX:-OmitStackTraceInFastThrow+>> The compiler in the server VM now provides correct stack backtraces for all "cold" built-in exceptions. For performance purposes, when such an exception is thrown a few times, the method may be recompiled. After recompilation, the compiler may choose a faster tactic using preallocated exceptions that do not provide a stack trace. To disable completely the use of preallocated exceptions, use this new flag: -XX:-OmitStackTraceInFastThrow.
-> built-in 예외가 반복적으로 발생할 경우 메소드를 다시 컴파일 하여 성능을 높일 수 있다. 재컴파일 이후, 컴파일러는 미리 할당된 예외를 던지는데, 이 예외에는 stack trace가 없다.+
  
-이 경우, **동일 JVM에서 비슷하게 발생한 다른 에러 로그를 찾아보면 과거에 발생했던 에러 로그에서 stacktrace를 찾을 수 있다.** +>> built-in 예외가 반복적으로 발생할 경우 메소드를 다시 컴파일 하여 성능을 높일 수 있다. 재컴파일 이후, 컴파일러는 미리 할당된 예외를 던지는데, 이 예외에는 stack trace가 없다. 
-원천적로 이 기능을 끄려면 ''-XX:-OmitStackTraceInFastThrow'' 옵션을 사용한다.+ 
 +원천적이로 이 기능을 끄려면 ''-XX:-OmitStackTraceInFastThrow'' 옵션을 사용한다. 하지만 굳이 이 옵션을 사용할 필요가 없다. 
 + 
 +이 경우, **동일 JVM에서 비슷하게 발생한 다른 에러 로그를 찾아보면 과거에 발생했던 에러 로그에서 stacktrace를 찾을 수 있다.** 혹은 JVM을 다시 실행해서 재현해봐도 전체 stacktrace를 얻을 수 있다. 
 + 
 +재현해보기 
 +<code java> 
 +public class NpeThief { 
 +  public void callManyNPEInLoop() { 
 +    for (int i = 0; i < 1000000; i++) { 
 +      try { 
 +        ((Object)null).getClass(); 
 +      } catch (Exception e) { 
 +        // stacktrace길가 2 다가 어느 순간 0으로 바뀐다. 
 +        System.out.println(e.getStackTrace().length); 
 +      } 
 +    } 
 +  } 
 +  public static void main(String ... args) { 
 +    NpeThief thief = new NpeThief(); 
 +    thief.callManyNPEInLoop(); 
 +  } 
 +
 +</code> 
 + 
 +===== -XX:+AlwaysPreTouch ===== 
 +  * ''-XX:+AlwaysPreTouch'' Heap Size가 클 경우 JVM이 뜰 때 미리 Heap 공간을 0으로 채워 초기화 해 둔다. 부팅 속도는 느려지지만 실행시 속도는 빨라진다. 
 + 
 +===== 참조 ===== 
 +  * [[https://www.baeldung.com/jvm-tuning-flags|Exploring JVM Tuning Flags | Baeldung]] 
 +  * [[https://javarevisited.blogspot.com/2011/11/hotspot-jvm-options-java-examples.html|10 Examples of HotSpot JVM Options in Java]] 
 +  * [[https://javarevisited.blogspot.com/2011/11/hotspot-jvm-options-java-examples.html|10 Examples of HotSpot JVM Options in Java]] 
 +  * [[https://javarevisited.blogspot.com/2012/06/what-is-xxusecompressedoops-in-64-bit.html|What is -XX:+UseCompressedOops in 64 bit JVM? Example]]
java/options.1502151722.txt.gz · 마지막으로 수정됨: 2017/08/08 08:52 저자 kwon37xi