1. Instantiation process: Cloning objects at the language level, creating objects, deserializing the generated objects by checking that the instantiated class is loaded (after the load, the class exists), whether it is parsed, initialized, and then allocates memory space (stored in the heap) for the new object, through the new keyword, the virtual opportunity, and the new directive. , sets the object header of the object instance, resets the object body to zero, and then executes the <init> method
2. Memory allocation: GC Collector algorithm--->> (whether with compression finishing function) The type of GC collector--->>java heap memory is structured (structured refers to whether the memory is composed of a complete block of memory, such as used memory is in one place, Not used in another place)--->>java memory allocation method
2.1 Memory allocation Method 1 (free list allocation): This allocation is due to the Java heap memory is not structured, used and unused memory interleaved, so that the virtual machine needs to maintain a list, the list of memory which memory is used, which memory is not used, in allocating space, not only to allocate space, And you want to record it in the list.
2.2 Memory allocation Method 2 (Pointer collision allocation): This allocation is the memory of the situation, the use of memory on one side, unused on the other side, the middle with a pointer as a demarcation indicator, if you want to allocate memory, the pointer to the free memory direction to move an object instance size memory space to hold the instance.
2.3 After allocating memory, the object's space exists, but there is no content (such as the contents of this object), so the Init method is used to assign a value to the property field in the object instance.
Pass: What is the method for assigning the value here? Is it through set mode?
3. Instance objects are divided into 3 part object headers, object bodies, aligned fills (not necessarily present)
3.1 The object header mainly records the HASHCODE,GC tag of the object, the metadata address, and the use of the object lock, age generation, bias thread, etc.
The 3.2 object body records the data that our programmers normally log, and generally we use only this part of the data, that is, the fields and their values in the object, the inherited fields, if the field is the base type, the address of the field name and the base type value that the field points to, and the address of the reference value if it is a reference type.
3.2.1 In fact, these values are in the local variable table in the virtual machine stack, where the base type data is stored in the local variable table, the starting address of the reference type (object), so the value of the field in the object body is the address in the local variable table.
3.3 The alignment fill exists to see if the object body is 8 bits, the JVM requires that the object instance size must be 8 bits (the memory unit must be byte), and the object header size is byte, so when the object body data can not fill the entire byte size of memory, you need to align the padding to complement.
3.4 The order in which fields are stored in the object body depends on the order in which it is defined in the class and the virtual machine assignment policy, which is the basic type of the allocation policy before the OOP type is behind (double/long>float>int>short/char>byte/ Boolean>oop (Ordinary object pointer)), in the same type of case, the parent class field precedes the Child class field.
Java Virtual machine Learning--creation of object instances