An in-depth understanding of the principles of the JVM is crucial for developers to tune performance, locate production failures, and allocate memory resources properly. The JVM is also a frequent interview topic, which is a necessary skill for Java developers and deserves in-depth understanding and writing. Good developers have a systematic network of knowledge, not just a fragmented technical scatter, and this series of articles attempts to connect working practice summaries with knowledge from classic JVM books. Including the JVM overall structure parameters, memory management, virtual machine configuration, algorithm and garbage collector, class file structure, class loading system, the bytecode execution, concurrent optimization, performance monitoring tools, tuning of actual combat several parts, each part is described in a separate article, this article mainly do integrity, clear the direction of the series, This article mainly refers to Teacher Zhou Zhiming’s “In-depth Understanding of Java Virtual Machine” and teacher Ge Yiming’s “Actual Combat Java Virtual Machine”, which belong to the study notes of classic books and will be updated continuously in the future.

A,JVM architecture

Macro introduction to the overall structure of JVM, briefly describes the class loading subsystem, Java stack, method area, Java heap, direct memory, local method stack, garbage collection system, PC register, bytecode execution engine several important components of the function and function.

Second, memory management

  • Runtime data area
  • Methods area
  • The heap area
  • Direct memory
  • The virtual machine stack
  • Local method stack
  • PC register

3. Configure VM parameters

  • The GC log
  • Class record/unload
  • System parameters
  • Heap zone configuration
  • Method area configuration
  • Direct memory configuration
  • The stack configuration
  • Cenozoic configuration
  • Heap overflow exception handling
  • JVM working mode

Garbage collection algorithm and collector

  • Fundamentals of Garbage Collection
    • The basic concept
    • accessibility
    • Reference types
  • Garbage collection algorithm
    • Reference counting
    • Mark clear
    • Mark copy
    • Tag to sort out
    • Generational recycling
  • Garbage collector
    • Serial
    • ParNew
    • Parallel Svavenge
    • Serail Old
    • CMS
    • Garbage First
    • Selection of collector

Class file structure

  • Class file structure
    • The magic number
    • version
    • Constant pool
    • Access to identify
    • Class, superclass, interface
    • The Class field
    • A Class method
    • Method execution body
  • Bytecode instruction
    • Bytecode and data types
    • Load and store instructions
    • Operation instruction
    • Type conversion instruction
    • Object creation and access directives
    • Operand stack management instructions
    • Control transfer instruction
    • Method calls and return directives
    • Exception handling instruction
    • Synchronization instructions

Class loading system

  • Class loading process
    • loading
    • validation
    • To prepare
    • parsing
    • Initialize the
  • Parental delegation model
  • Custom class loaders

Bytecode execution

  • Run time stack frame structure
  • Methods to perform
  • Dynamic method invocation
  • ASM
  • Java Agent

Concurrency optimization

  • hardware
  • Main memory vs. working memory
  • concurrency
    • atomic
    • visibility
    • order
  • volatile
  • synchronized
  • Lock
  • Lock the optimization
    • spinlocks
    • Adaptive spin
    • Lock elimination
    • Lock coarsening
    • Lightweight lock
    • Biased locking

Performance monitoring tool

  • Common commands
    • top
    • jps
    • jinfo
    • jmap
    • jhat
    • jstack
  • tool
    • JConsole
    • Visual VM
    • Arthas

Ten, tuning actual combat

  • Tomcat garbage collection performance tuning
  • Production inspection and actual combat