In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces what is the memory model of the java virtual machine, the content is very detailed, interested friends can refer to, hope to be helpful to you.
The difference between Java memory structure and java memory model. Often a lot of people will do it. Here, we mainly explain and operate these two kinds. In practice, there is a big difference between JVM tuning and no JVM tuning, which can double the performance of the server.
Java memory structure: the so-called heap, stack, method area, and native method stack java memory model:
Image.png
Image.png
Image.png
Image.png
Image.png
Image.png
This stack is allocated where it is set in idea
Image.png
If the new generation setting is relatively small, garbage collection will frequently collect, otherwise memory is not enough, frequent collection will affect performance, and non-collection will lead to memory overflow, so this ratio is very critical. Generally, set the virtual machine memory size for the current PC memory size, the new generation and the old memory ratio is 1:2, generally the old age will be more, because this can reduce the number of garbage collection and improve performance. The initial heap memory is the same as the maximum heap memory setting. Memory overflow, stack overflow and heap overflow. Stack overflow is like the following endless loop. The int declared in the stack can only reach a certain number.
Image.png
Image.png
Summary: jvm parameter tuning, mainly set heap memory, mainly let gc not to frequently collect garbage, reduce the collection of old times.
Image.png
Here is an extra point of knowledge: what is a daemon thread gc thread is a daemon thread: the main thread is dead, the gc thread is also dead, the non-daemon thread is dead, but the new Thread is still executing. If you want to turn a non-daemon thread into a daemon thread, you need to use join, for example: new Thread (). SetDeamon ()
Image.png
Next, several algorithms of garbage collection mechanism are introduced. Citation calculation method
Image.png
two。 Label removal algorithm
Image.png
3. Replication algorithm. The disadvantage is that the available memory is half of the original memory.
Image.png
4. Label compression algorithm
Image.png
5.GC generation algorithm is based on the new generation and the old generation of garbage collection, generally more new generation of recycling, the old era of recycling less, so we should avoid the old era of gc recovery, the old era recovery is relatively slow when the phenomenon of garbage recovery every time gc recovery, all other threads will stop, if there is no pause, then it is possible to use objects, or new objects, not easy to clean up garbage. Garbage collector: serial collection-single thread (single core recovery) parallel recovery-multi-thread (multi-core recovery) enterprises use more, good performance CMS recovery-parallel GC, using label removal algorithm for recovery, the performance is the best, generally use parallel recovery can be G1 recovery, is proposed in jdk1.7, with less test interface throughput
Launch the jmeter test tool, the stress test tool, and mainly test the throughput of the website, that is, how many times it can be accessed per second.
Image.png
Image.png
Image.png
Image.png
Image.png
On the java virtual machine memory model is shared here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.