Fundamentals 14 min read

Fundamental Computer Concepts and Java JVM Memory Architecture

This article explains basic computer concepts such as storage units, registers, memory hierarchy, kernel and user space, CPU word length, and then details the Java Virtual Machine's runtime data areas, object creation process, and object reference mechanisms.

Java Captain
Java Captain
Java Captain
Fundamental Computer Concepts and Java JVM Memory Architecture

This article aims to consolidate basic computer concepts and provide a reference for future writing, covering storage units, memory components, address bus implications, kernel vs. user space, and CPU word length.

1. Computer storage units

The hierarchy from smallest to largest is Bit, Byte, Kilobyte (KB), Megabyte (M), Gigabyte (GB), Terabyte (TB), with each adjacent unit being 1024 times larger (2^10).

1 Byte = 8 bits

1 KB = 1024 Bytes

1 MB = 1024 KB

1 GB = 1024 MB

1 TB = 1024 GB

2. Computer storage components

Register: part of the CPU, the fastest storage but with very limited capacity.

Memory (RAM): an independent component that acts as a bridge between the CPU and external storage, holding computation data and data exchanged with external memory. Although modern RAM is fast, it is still orders of magnitude slower than registers, and its I/O operations cannot be eliminated.

3. Kernel space and user space

The address bus connects memory and registers; its width determines the physical address range and how many bits can be fetched at once. For example, a 32‑bit CPU can address 4 GB of memory, but the operating system divides this space into kernel space and user space, with applications only allowed to use the user‑space portion.

4. Word length

Word length indicates how many bits the CPU can process in parallel. Modern CPUs are typically 64‑bit, though many systems still run in 32‑bit mode.

Preface

When discussing Java memory areas, many think only of the heap and stack, but the JVM actually defines several distinct runtime data regions, each with its own purpose and lifecycle.

Runtime Data Areas

The JVM defines several memory regions used during program execution, as illustrated in the diagram (image omitted for brevity).

1. Thread‑local memory regions

(1) Program Counter Register – a small area that holds the current bytecode line number for each thread.

(2) Java Stack – stores local variables, operand stack, dynamic linking information, and method return data for each method invocation. Stack size typically ranges from 256 KB to 756 KB.

(3) Native Method Stack – serves native methods; HotSpot merges this with the Java stack.

2. Shared memory regions

(1) Heap – the largest memory area managed by the JVM, holding all object instances. It is divided into generations (young and old) and further into Eden, From‑Survivor, and To‑Survivor spaces.

(2) Method Area – stores class metadata, constant pools, static variables, and JIT‑compiled code. In older HotSpot versions this was the “PermGen”; newer versions use native memory.

(3) Runtime Constant Pool – part of the method area that holds literals and symbolic references, which can also be populated at runtime (e.g., via String.intern() ).

3. Direct memory

Although not defined by the JVM specification, direct memory (allocated via NIO's DirectByteBuffer ) resides outside the Java heap and can improve performance by avoiding copying between Java and native buffers.

Object Creation

Creating an object in Java involves several JVM steps:

The JVM encounters a new instruction, resolves the class reference, and ensures the class is loaded, linked, and initialized.

Memory is allocated in the heap. Allocation may use a pointer‑bumping technique (if the heap is contiguous) or a free‑list approach (if the heap is fragmented), depending on the garbage collector.

The allocated memory is zero‑filled (excluding the object header).

Object metadata such as class pointer, hash code, and GC generation age are set in the object header.

The constructor ( <init> ) is executed to perform user‑defined initialization.

Reference handling in Java is implementation‑dependent. Two common schemes are:

Handle access – a handle table stores pointers to class data and instance data; the reference points to the handle.

Direct pointer access – the reference points straight to the object, which contains both class and instance data. HotSpot uses the latter.

Java Virtual Machine Series

For further reading, see the linked article "Java Virtual Machine: What is Java".

Original source: cnblogs.com/xrq730/p/4827590.html

Promotional Section

Java Group – focused on sharing Java knowledge. Scan the QR code for more Java resources.

JavaJVMmemory hierarchyCPU architecturecomputer fundamentalsobject allocation
Java Captain
Written by

Java Captain

Focused on Java technologies: SSM, the Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading; occasionally covers DevOps tools like Jenkins, Nexus, Docker, ELK; shares practical tech insights and is dedicated to full‑stack Java development.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.