Download pptx - Inside the jvm

Transcript
Page 1: Inside the jvm

Inside the JVMSTRUCTURE OF JAVA VIRTUAL MACHINE

Development Center @ Pikicast.com김병부 ( Benjamin )

Page 2: Inside the jvm

Benjamin : about me

Pikicast Netmarble U-Angel Joins.com and etc

Page 3: Inside the jvm

因果關係 : 인과관계

System Crash, Service Crash. Application Crash 서비스가 죽는 것은 항상 원인이 있습니다 시스템이 원인인지 , 어플리케이션이 원인인지 , 데이터 베이스가 원인인지 알아야 같은 현상을 막을 수 있습니다 . 서비스는 한번에 죽지 않습니다 . 서서히 죽어갈 뿐입니다 .

건강 검진 or 사후 검증 Thread dump Heap dump

Page 4: Inside the jvm

List of JVM

List of JVM?? The Java Virtual Machine Specification

Hotspot JVM Open JVM IBM JVM TinyVM Dalvik JM ??

Stack Machine vs Register Machine

Page 5: Inside the jvm

JVM : Java Virtual Machine #1

Class File Bytecode 의 집합 Interpreter / JIT Compiler

Java Stack Heap

Thread 들이 공유하는 메모리 영역 Method Area

Thread 들이 공유하는 메모리 영역 Class 변수 , 상수 , Class 정보 , Method 정보

Page 6: Inside the jvm

Thread1st Keyword inside of the JVM

Page 7: Inside the jvm

Thread State : java.lang.Thread.State

NEW RUNNABLE TIMED_WAITING WAITING BLOCKED TERMINATED

Since Java 1.5

Page 8: Inside the jvm
Page 9: Inside the jvm

Thread :list of thread in the Hotspot JVM

Thread 종류 Non – Daemon Thread :

E.g. Thread, VM Thread Daemon Thread :

Garbage Collector Thread, JMX Monitoring Thread System Threads

VM thread GC threads Periodic task thread – timer events i.e. interrupts for schedule Compiler thread – compiles byte code to native code in runtime

Page 10: Inside the jvm

Thread: Multi-Thread

Each thread has .. Program Counter (PC) Stack Native stack Stack Frame

Multi Thread – Context Switching & Scheduling Thread-Safe

Keyword – synchronized

Page 11: Inside the jvm

JVM Stack

JVM Stack per Thread!!! Stack Frame per Method

Local Variable Array Operand Stack Reference to Constant Pool

Page 12: Inside the jvm

Thread dump: How to dump JVM Thread

jstack [pid] or kill –3 [pid]Thread Dump Date JVM Type, Mode

Thread name

Thread Priority Thread ID Native

Thread ID

Thread STATUS

Thread STACK info

Page 13: Inside the jvm

Thread Dump Tool : IBM Thread and Monitor Dump Analyzer for Java

Page 14: Inside the jvm

Heap Area2nd Keyword inside of the JVM

Page 15: Inside the jvm

JVM Memory Structure: with JVM options

Basic Structure Depends on GC options Promotion Minor GC vs Major GC

Young Generation Old and Perm Generation STW – Stop the world

From Java8, No more PERM gen. Metaspace (Native Heap)

Page 16: Inside the jvm

What is difference between Method Area and PERM GEN?

Actually the Method Area is a part of the PERM GEN

A third generation closely related to the tenured generation is the permanent generation. The permanent generation is special because it holds data needed by the virtual machine to describe objects that do not have an equivalence at the Java language level. For example objects describing classes and methods are stored in the permanent generation.

Page 17: Inside the jvm

Thread and Heap: Reference from Stack to Heap

Stream API?

Page 18: Inside the jvm

Garbage Collection

GC options Serial GC, Parallel GC – Mark, Sweep, Compact Incremental GC CMS G1GC

Page 19: Inside the jvm

CMS vs G1GC

CMS GC Concurrent – Mark – Sweep GC more CPU,

G1GC Garbage-First GC Region Recommend over 4G memory

Page 20: Inside the jvm

Heap Dump: How to dump JVM Heap

jmap –dump:format=b,file=[file name].hprof [PID] JVM 메모리 사이즈 만큼의 binary 파일이 생성된다 . Binary 파일이므로 분석툴이 필요함 .

Page 21: Inside the jvm

Heap Dump Tool : IBM HeapAnalyzer Or Eclipse Memory Analyzer

Page 22: Inside the jvm
Page 23: Inside the jvm

OOME Case : Out Of Memory Exception

java.lang.OutOfMemoryError : Java heap space java.lang.OutOfMemoryError : PermGen space java.lang.OutOfMemoryError : Request array size exceeds VM

limit

Page 24: Inside the jvm

ConclusionConclusion inside of the JVM

Page 25: Inside the jvm

Note

Dump 는 10 초 간격으로 3 번씩 뜬다 . Perm 영역에서도 OOM 이 발생할 수도 있다 . Hotspot JVM > Open JVM Async Process 가 만능은 아님

MultiThread 도 Pool 로 관리하자 Thread-safe and Pool Management

우리에겐 G1GC 가 가장 맞는 케이스 Throughput based tuning Response time based tuning 튜닝의 끝은 순정

Page 27: Inside the jvm

Thank you