1. Overview

In this quick tutorial, we’re going to see how and where the HotSpot JVM stores the array length.

Usually, the memory layout of run-time data areas is not part of the JVM specification and is left to the discretion of the implementor. Therefore, each JVM implementation may have a different strategy to layout objects and arrays in memory.

In this tutorial, we’re focusing on one specific JVM implementation: the HotSpot JVM. We also may use the JVM and HotSpot JVM terms interchangeably.

2. Dependency

In order to inspect the memory layout of arrays in the JVM, we’re going to use the Java Object Layout (JOL) tool. Therefore, we need to add the  jol-core dependency:

#java #jvm

Where Is the Array Length Stored in JVM?
1.25 GEEK