In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
There are two ways to divide objects:
Pointer collision: java memory space regular please use under the paragraph
Free list: java memory space irregular please use under the paragraph
Concurrency security issues: frequent object creation can lead to thread insecurity. There are two solutions:
1. The operation of allocating memory space is processed synchronously, CAS plus failure retry mechanism ensures atomicity of update operation.
2. Allocation buffer: allocate independent space to each thread (apply for a small piece of private memory in Java heap), that is, Tread Local Allocation Buffer (TLAB), turn on-XX:+UseTLAB, allocate in its own Buffer, space is not enough to re-apply for a piece in Eden area to continue using.
TLAB allows each application thread to have its own allocation pointer to allocate space (Eden zone, 1% of Eden by default), reducing synchronization overhead.
TLAB only allows each thread to have a private allocation pointer, but the memory space below the object is still accessible to all threads, but other threads cannot allocate it in this area. When a TLAB is full (allocation pointer top hits allocation limit end), reapply for a TLAB.
Object Memory Layout
In HotSpot virtual machine, the memory layout of objects is divided into: Header, instance Data and padding
Object header allocation has two parts, one is its own runtime data (hash code), GC banding age, lock status flag, thread holding lock, bias thread ID, bias timestamp, etc.
Another type of pointer is a pointer to only its class element, which the virtual machine uses to determine which class instance it is.
The aligned fill acts as a placeholder. Object size must be 8 bytes. 7 bytes of instance data fill 1 byte, and 1 byte fills 7 bytes.
How to access an object
Handle: Java heap is divided into a block of memory as a handle pool, reference stores object handle address, handle contains object instance data and type data of the respective specific address information.
Direct pointer: reference directly stores the address of the object.
The benefits of handles are that only the instance data pointer changes when the object is moved (garbage collection moves the object), while the reference itself does not need to be modified. The biggest advantage of direct pointer mode is that it is faster and reduces the time overhead of pointer setting. For Sun HotSpot, it is object access using direct pointer access.
memory allocation strategy
-XX:SurvivorRatio=8, represents the ratio of Eden to Survivor, default is 8 means Eden:From(Survivor):To(Survivor)=8:1:1
-XX:SurvivorRatio=2 means 2:1:1
Two Survivor zones are set up to solve the fragmentation problem (copy recycling algorithm)
Objects with Present Eden Zone Assignment Large Objects Direct Entry Old Age Long-lived Objects Entry Old Age Dynamic Objects Age Determination Space Assignment Guarantee
-Xms:20m stack space 20m
-Xmx:20m maximum stack space 20m
-Xmn:10m Cenozoic (Eden zone)10m
-XX:+ PrintGC Details Print GC logs
-XX:+UseSeriolGC A garbage collector type
-XX:PretenureSizeThreshold=2m Subjects exceeding 2M can directly enter the elderly generation
Long-term survival:
Eden area 8m occupied, redistribute 1m objects, Eden area will occur MinGC.
Surviving objects enter the from zone, age +1, garbage collection enters the to zone, age +1.
Garbage collection is performed again, the object returns to the from area, the age is +1, and the from and to areas are repeated, because the from and to areas adopt the copy collection algorithm.
Age up to 15 years old, belong to the long-term survival object, enter the elderly generation.
Dynamic object age judgment:
The age of the from and to zones adds up to half of the age of the from, and you can advance to the old age.
Space allocation guarantee: HandlePromotionFailure, do not consider the old age space is not enough, do not consider the occurrence of FullGC, if the guarantee fails or there is not enough memory will also be a FullGC
FullGC: FullGC will be executed when there is insufficient space in the old era and there is a from or to zone upgrade into the old era.
generic
Generic erasure (for implementation)
Weak memory (version compatibility)
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.