In previous studies, everyone must have heard of the object head. We know that object headers can be used to store information, but many people may not have tried it on specific storage types. It is divided into two types: storing the data and type pointer of the object itself. The latter has relatively little contact with everyone. We will introduce the concepts separately in the following articles. The specific contents are as follows.
1. The object header is mainly used to store two pieces of information.
Store data about the operation of the object itself
type pointer
2. The data when the object itself is running mainly includes: hash code, GC generation age, lock status flag, lock held by the thread, biased thread ID, biased timestamp, etc. The length of this part of data is 32 bits and 64 bits respectively in 32-bit and 64-bit virtual machines (compressed pointers are not enabled).
The type pointer can be used to determine which class this object is an instance of, but the implementation of the virtual machine does not have to retain the type pointer on the object.
The above are the two storage types of Java object headers. Friends who have never been exposed to them can do some practical experiments on these two different storages after class.