Technology Sharing

Basic introduction to JVM (1)

2024-07-11

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

This article is the first article in the "In-depth Study of JVM" series, which mainly introduces the functions of JVM and its three major subsystems.
I amMosquito Coder, welcome your likes, attention and collection. With your encouragement, I will bring better works.

1. Introduction to JVM

JVM, which stands for Java Virtual Machine, is also known as Java Virtual Machine in Chinese.
itseffect, is to convert the project code we wrote intooperating systemThe source code can be understood and then run on the machine.
Its outstanding ability is to make the code truly independent of the machine. No matter what kind of machine it is, as long as the JVM is implemented, the same class file can get the same running results.
JVM runs on the operating system. From the perspective of the operating system, it is an ordinary process. From the perspective of Java developers, it implements excellent encapsulation. We don't know much about it, but we only know that it is a necessary tool for running Java projects.
Try to dissect this mysterious machine.

2. What to learn when learning JVM?

JVM is equivalent to the operating system running on the operating system, so we analyze the JVM from the perspective of the operating system.
We know that the five major functions of an operating system are: memory management, process management, CPU management, storage management, and IO management.

First, memory management strategy

Since JVM is not a real operating system after all, we mainly learn its advancedMemory management strategy
We all know that in Java, there is no need to manually apply for memory or manually release memory. This is a very advanced "automatic memory management strategy".

Second, performance tuning strategy

In actual work, we rarely deal with memory directly, but more often perform tuning, so tuning methods are also essential.

3. Analyzing the JVM

We know that after completing the Java project, we need to firstCompile, in order to make it run on the JVM.
The compiled file is a class file, which will be translated into a certain structure on the JVM so that it can run.
This is the first thing to learn.Class file conversion system
No matter what structure the class file is ultimately converted into, the data needs to be implemented in memory.
This is the second knowledge.Runtime data area
JVM is a process on the operating system, so it can control the CPU for a period of time. At this time, how do we run our main statement?
This is the third knowledge.Execution Engine

IV. Conclusion

I amMosquito CoderIf you have any additions or questions, please leave a message in the comment area. My personal knowledge system may not be so perfect, I hope you can correct me, thank you.