In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "the composition and allocation of JVM memory". In daily operation, I believe many people have doubts about the composition and allocation of JVM memory. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "composition and allocation of JVM memory". Next, please follow the editor to study!
Introduction to java memory composition: heap (Heap) and nonheap (Non-heap) memory
Officially, "the Java virtual machine has a heap, which is the runtime data area from which all class instances and arrays of memory are allocated. The heap is created when the Java virtual machine starts."memory outside the heap in JVM is called non-heap memory (Non-heap memory). You can see that JVM manages two main types of memory: heap and non-heap. Simply put, the heap is the memory available to Java code, which is reserved for developers; non-heap is reserved for JVM's own use, so the method area, memory needed for internal processing or optimization in JVM (such as JIT compiled code cache), each class structure (such as runtime constant pools, fields and method data), and the code for methods and constructors are all in non-heap memory.
Composition diagram
◆ method stack & local method stack:
Generated when the thread is created, and stack frame is generated when the method is executed
◆ method area
Metadata, information, constants, etc., of storage classes
◆ reactor
All new operations in java code
◆ native Memory (C heap)
Direct Bytebuffer JNI Compile GC
Heap memory allocation
The memory initially allocated by JVM is specified by-Xms. The default is 1x64 of physical memory. JVM allocated memory is specified by-Xmx, and the default is 1x4 of physical memory. When the default free heap memory is less than 40%, JVM will increase the heap to-Xmx limit; when the free heap memory is greater than 70%, JVM will reduce the minimum heap to-Xms limit. So servers generally set-Xms and-Xmx equal to avoid resizing the heap after each GC. Object's heap memory is reclaimed by an automatic memory management system called the garbage collector.
Group detailed solution Young Generation, that is, Eden + From Space + To Space in the diagram
Eden
Store new objects
Survivor Space
There are two, which store the object Old GenerationTenured Generation that survives after each garbage collection, namely the Old Space in the figure.
It mainly stores living objects with long life cycle in the application.
Non-heap memory allocation
JVM uses-XX:PermSize to set the initial value of non-heap memory, which defaults to 1x64 of physical memory, while XX:MaxPermSize sets the size of * * non-heap memory, which defaults to 1x4 of physical memory.
Permanent Generation saves the virtual machine's own static (refective) data
Mainly stores loaded Class class-level static objects such as class itself, method,field, etc.
Insufficient permanent generation space causes full GC (see HotSpot VM GC category for details) memory that Code Cache uses to compile and save native code (native code)
JVM internal processing or optimization
JVM memory limit (* value)
The value of JVM memory has a lot to do with the operating system. To put it simply, 32-bit processors have 4GB in controllable memory space, but the specific operating system will give a limit. This limit is generally 2GB-3GB (generally speaking, it is 1.5g in Windows system, it is 2G-3G in Linux system), and there will be no limit on processors above 64bit.
At this point, the study on the composition and allocation of JVM memory is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.