当前位置:网站首页>What is JVM? What are the purposes of JVM tuning?

What is JVM? What are the purposes of JVM tuning?

2022-07-07 04:39:00 Blue92120

jvm The composition of

jvm Is one that can run java The virtual machine of bytecode . Loading subsystems by classes 、 Run time data area ( Memory model ) And bytecode execution engine , Cross platform , Shield the differences between the underlying hardware and instructions of different operating systems from the software level , Write in one place and run in multiple places. Pass before running javac The command will be converted to a bytecode file , When bytecode file is running JVM So I started to work .

1. Class loading subsystem

2. Run time data area :

Pile up : new The objects that come out are put in the heap , It is divided into old age and young generation , The elderly account for the whole pile 2/3, Younger generation 1/3. The young generation is divided into three parts : Eden Park ,survivor District (s0 and s1), The proportion 8:1:1 . When the objects in Eden Park are full , Bytecode engine will execute a garbage collection thread (minor( Pretty ) gc) Copy non garbage objects to survivor District , Then delete the garbage object

Stack : As long as one thread is running ,Java The virtual machine will allocate a little memory space to this thread , This space is called thread stack ( Used to put its own local variables inside the method ) A method corresponds to a stack frame memory area

Program counter : Each program will be assigned a program counter when it runs , Record the memory address of the code to be executed immediately , The function is that the current thread is robbed of the execution right , When resuming execution, continue to run from the recorded memory address

Method area : Store constants , Static variables , Class information ( After the bytecode file is loaded, it is placed in the method area )

Native Method Stack : The memory space allocated when executing local methods is provided by the local method stack , The underlying use C C++ The method of language writing is the local method

3. Bytecode execution engine

jvm tuning

Tuning purpose : The user process will be stopped when garbage is collected (STW) stop the word , Concentrate on garbage collection , Reduce GC(minor full)

Why would there be SWT: When the program is running , There's garbage ,full GC Start looking for garbage , Start with local variables and find all objects , Are marked as non garbage objects , Then looking for other variables . If there is a thread ,GC The thread is not finished yet , It's over first , Then the stack memory space in it will be released , Releasing it means that the local variable table is gone , Local variables are also destroyed , That just GC When looking for garbage, clearly mark these objects as not garbage objects , Now it's garbage again , This is not appropriate . So when recycling garbage , Let the user thread stop first , Don't affect the state of the object , Mark it and then clean up the garbage , Maybe the performance is a little higher

Can it be right? JVM tuning , Make it almost impossible Full GC :

Tuning Tools : Arthas( Alsace ) It is open source by Alibaba java Diagnostic tools , Support JDK6+, Use command line interaction mode . Easy to use , Monitor progress .

原网站

版权声明
本文为[Blue92120]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207062202486060.html

随机推荐