Why do Java objects have to be multiples of 8?
•
Java
I know Java uses padding; The object must be a multiple of 8 bytes But I don't see its purpose What is it for? What is its main purpose?
Solution
Its purpose is alignment, which allows faster memory access at the cost of less space If the data is not aligned, the processor needs to make some transformations to access it after loading memory
In addition, garbage collection is simplified (Accelerated) the larger the size of the minimum allocation unit
Java is unlikely to require 8 bytes (except for 64 bit systems), but since 32-bit architecture is conventional when Java is created, 4-byte alignment is required in Java standard
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码