The JVM tuning

  1. concept
  2. Basic garbage collection algorithm
  3. Problems with garbage collection
  4. Generational garbage collection detail 1
  5. Generational garbage collection detail 2
  6. Typical Configuration Example 1
  7. Typical Configuration Example 2
  8. A new generation of garbage collection algorithms
  9. Tuning method
  10. reflection

What is the JVM?

The JVM is undoubtedly one of the hottest technologies in the Internet industry

The JVM, short for Java Virtual Machine, is a specification for computing devices. The JVM is an imaginary computer that is implemented by emulating various computer functions on an actual computer.

A very important feature of the Java language is platform independence. The use of Java virtual machine is the key to achieve this feature. Normal high-level languages need to be compiled into at least different object code if they are to run on different platforms. With the introduction of the Java language VIRTUAL machine, the Java language does not need to be recompiled when running on different platforms. The Java language uses the Java Virtual machine to mask platform-specific information, allowing Java language compilers to run unmodified on multiple platforms by generating object code (bytecode) that runs on the Java Virtual machine. When the Java virtual machine executes bytecodes, it interprets the bytecodes as machine instructions on a specific platform. This is why Java has the ability to “compile once, run anywhere”.

What are the features of the JVM?

1. Portability

Both GC and Hotspot can be used wherever Java is available. For example, if JRuby runs on other platforms, Rails applications can run on JRuby on an IBM host running CP/CMS. In fact, as Java and OpenJDK projects become open source, we’re seeing more and more platform spin-offs, so the PORTABILITY of the JVM is getting better.

2, mature

The JVM has been around for many years, and many developers have contributed to it over the years, improving its performance time and time again, making it more stable, faster, and more widespread.

3. Coverage

JRuby and other language projects on the JVM have been recognized; an example is the InvokeDynamic Specification (akaJSR292). JSR is becoming more compatible with new languages, and the JVM is no longer Java’s sole custom rule. The JVM is building into a great platform for projects like JRuby. There is also the MLVM (Multiple Language M) project, which is like a clearinghouse for new features, a place where many enterprise application developers try to add applications that they want to see in the JVM. Moreover, JVM developers collaborate and influence each other, which undoubtedly facilitates the creation of new JVM features. These details show that the JVM is paying attention to the needs of developers and expanding its reach.

Add assistant VX: Yunduoa2019 or scan the following public account for free to receive the history of the most complete JVM actual combat document

 

JVM memory region partitioning

1. Program counter (thread private)

2Java stack (thread private)

3. Local method stack (thread private)

4. Heap (thread sharing)

5. Method area (thread sharing)

6. Direct memory (thread sharing)

 

 

JVM Execution Subsystem

1.Class file structure

  • 1.1 Java cross-platform foundation
  • 1.2 The nature of the Class

Bytecode instructions

  • 2.1 Load and store instructions
  • 2.2 Operations or arithmetic instructions
  • 2.3 Type conversion instructions
  • 2.4 Directives for creating class instances:
  • 2.5 Instructions for creating arrays:
  • 2.6 Access field instructions:
  • 2.7 Array access instructions
  • 2.8 Directives to check class instance types:
  • 2.9 Operation Data Management instructions
  • 2.10 Control transfer instruction
  • 2.11 Method Call instruction
  • 2.12 Method return instruction
  • 2.13 Exception Handling Instructions
  • 2.14 Synchronization Command

3. Class loading mechanism

Class loaders

  • 4.1 Class loader for the system
  • 4.2 Parental delegation model

5.Tomcat class loading mechanism

6. Method call details

  • 6.1 analytical
  • 6.2 Static Dispatch
  • 6.3 Dynamic Dispatch
  • 6.4 Stack – based bytecode interpretation execution engine

 

 

Garbage collector and memory allocation policy

1. Is value passing or reference passing in Java?

2. Reference types

3. Basic garbage collection algorithm

  • 3.1 By basic recycling policy
  • 3.2 According to the way of partition treatment
  • 3.3 By system thread

4. Dispose of garbage by generation

5. The type of garbage collection IN JAVA

 

 

Write efficient and elegant Java programs

1. Object oriented

  • 1.1 What if there are too many constructor parameters?
  • 1.2 Classes that do not need to be instantiated should be constructor private
  • 1.3 Don’t create unnecessary objects
  • 1.4 Avoid finalization methods
  • 1.5 Minimize the accessibility of classes and members
  • 1.6 Minimize variability
  • 1.7 Composition takes precedence over inheritance
  • 1.8 Interfaces over Abstract Classes

Method 2.

  • 2.1 Variable parameters should be used with caution
  • 2.2 Return a zero-length array or collection. Do not return NULL
  • 2.3 Use standard exceptions in preference

3. General programming

 

 

Add assistant VX: Yunduoa2019 or scan the following public account for free to receive the history of the most complete JVM actual combat document

 

Performance optimization

1. Commonly used performance evaluation test indicators

1.1 Response time

1.2 concurrency

1.3 throughput

2. Common performance optimization methods

2.1 Avoid premature optimization

2.2 Testing system performance

2.3 Look for system bottlenecks, divide and conquer, and gradually optimize

2.4 Common means of front-end optimization

  • 2.4.1 Browser /App
  • 2.4.2 the CDN to accelerate
  • 2.4.3 Reverse proxy Caching
  • 2.4.4 Separating WEB Components

3. Application service performance optimization

3.1 the cache

  • 3.1.1 Basic principles and nature of caching
  • 3.1.2 Guidelines for reasonable use of buffering
  • 3.1.3 Distributed caching and consistent hashing

3.2 the asynchronous

  • 3.2.1 Synchronous and asynchronous, blocked and non-blocked
  • 3.2.2 Common asynchronous means

3.3 the cluster

3.4 Application Related

  • 3.4.1 Code level
  • 3.4.2 Concurrent programming
  • 3.4.3 Resource Overcommitment
  • 3.4.4 JVM
  • 3.4.5 GC tuning
  • 3.4.6 Tuning actual combat
  • 3.4.7 Storage Performance Optimization

 

 

Add assistant VX: Yunduoa2019 or scan the following public account for free to receive the history of the most complete JVM actual combat document

 

Total directory