Inside the jvm

Embed Size (px)

Text of Inside the jvm

Spring Boot ?

Inside the JVMStructure of Java virtual machine Development Center @ ( Benjamin )

Benjamin : about and etc

: System Crash, Service Crash. Application Crash , , . . . or Thread dumpHeap dump

List of JVM

List of JVM??The Java Virtual Machine SpecificationHotspot JVMOpen JVMIBM JVMTinyVMDalvik JM ??Stack Machine vs Register Machine

JVM : Java Virtual Machine #1Class FileBytecode Interpreter / JIT Compiler Java StackHeap Thread Method Area Thread Class , , Class , Method

Java byte code is interpreted however this is not as fast as directly executing native code on the JVMs host CPU. To improve performance the Oracle Hotspot VM looks for hot areas of byte code that are executed regularly and compiles these to native code. The native code is then stored in the code cache in non-heap memory. In this way the Hotspot VM tries to choose the most appropriate way to trade-off the extra time it takes to compile code verses the extra time it take to execute interpreted code.5

Thread1st Keyword inside of the JVM


Since Java 1.5

Thread :list of thread in the Hotspot JVMThread Non Daemon Thread : E.g. Thread, VM ThreadDaemon Thread :Garbage Collector Thread, JMX Monitoring ThreadSystem ThreadsVM threadGC threads Periodic task thread timer events i.e. interrupts for scheduleCompiler thread compiles byte code to native code in runtime

. , Java . , JMX . 'static void main(String[] args)' , . main HotSpot VM VM Thread .9

Thread: Multi-ThreadEach thread has ..Program Counter (PC)StackNative stack Stack FrameMulti Thread Context Switching & SchedulingThread-SafeKeyword synchronized

Each frame contains:- Local variable array- Return value- Operand stackReference to runtime constant pool for class of the current methodProgram counter CPU


JVM StackJVM Stack per Thread!!!Stack Frame per MethodLocal Variable ArrayOperand StackReference to Constant Pool

Reference to Constant Pool : , . , JVM .11

Thread dump: How to dump JVM Threadjstack [pid] or kill 3 [pid]

Thread Dump DateJVM Type, ModeThread nameThread PriorityThread IDNative Thread IDThread STATUSThread STACK info

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

Heap Area2nd Keyword inside of the JVM

JVM Memory Structure: with JVM optionsBasic StructureDepends on GC optionsPromotionMinor GC vs Major GCYoung Generation Old and Perm GenerationSTW Stop the worldFrom Java8, No more PERM gen. Metaspace (Native Heap)

OLD generation == Tenured generation


What is difference between Method Area and PERM GEN?Actually the Method Area is a part of the PERM GENA 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.

Thread and Heap: Reference from Stack to Heap

Stream API?

Garbage CollectionGC optionsSerial GC, Parallel GC Mark, Sweep, CompactIncremental GCCMSG1GC

CMS vs G1GCCMS GCConcurrent Mark Sweep GCmore CPU, G1GCGarbage-First GCRegionRecommend over 4G memory

Heap Dump: How to dump JVM Heapjmap dump:format=b,file=[file name].hprof [PID]JVM binary .Binary .

Heap Dump Tool : IBM HeapAnalyzer Or Eclipse Memory Analyzer

OOME Case : Out Of Memory Exceptionjava.lang.OutOfMemoryError : Java heap spacejava.lang.OutOfMemoryError : PermGen spacejava.lang.OutOfMemoryError : Request array size exceeds VM limit

ConclusionConclusion inside of the JVM


Dump 10 3 .Perm OOM .Hotspot JVM > Open JVMAsync Process MultiThread Pool Thread-safe and Pool Management G1GC Throughput based tuningResponse time based tuning


Thank you