Issues related to hotspot virtual machine objects

Source: Internet
Author: User
Tags advantage

2016-07-16

Hotspot Virtual Machine Object

Issue 1: How to resolve both object A and object B to allocate memory using the original pointer when allocating memory space.

There are two ways to solve this problem:

1) synchronous processing of the action of allocating memory space-in fact, the CAS used by the virtual machine with the failure retry to ensure the atomicity of the update operation.

2) The memory allocation action is divided into different space by thread, that is, each thread allocates a small chunk of memory in the Java heap, called the local thread allocation buffer (TLAB).

Issue 2: The layout that is stored in memory for objects in the hotspot virtual machine can be divided into 3 blocks: What are their characteristics?

Object header, instance data, aligned padding.

(1) Object header

The object header of a hotspot virtual machine consists of two parts: 1) used to store its own runtime data, such as hash code, GC generational age, lock status flag, thread-held lock, bias thread ID, and time stamp bias. 2) The other part is the type pointer, which is the pointer to its class metadata, which the virtual machine uses to determine which class the object is an instance of.

(2) Example data

The instance data section is a valid piece of information that the object actually stores, as well as the various types of field content defined in the program code.

(3) Align fill

Alignment fills are not necessarily present. Just play the role of placeholder.

Question 3: How the current mainstream Access objects are accessed.

The main way to access objects is to use handles and direct pointers in two ways.

1) Use the handle. Memory divides the handle pool, which is the handle address of the object stored in reference, and the handle contains the respective address information of the object instance data and type data.     The advantage is that a stable handle address is stored in the reference, and the object moves only when the instance data pointer in the handle is changed, and the reference itself does not need to be modified. 2) Direct pointer. The object's address is stored directly in the reference. The advantage is that it's faster.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.