Partner – Moderne – NPI EA (cat=Spring Boot)
announcement - icon

Refactor Java code safely — and automatically — with OpenRewrite.

Refactoring big codebases by hand is slow, risky, and easy to put off. That’s where OpenRewrite comes in. The open-source framework for large-scale, automated code transformations helps teams modernize safely and consistently.

Each month, the creators and maintainers of OpenRewrite at Moderne run live, hands-on training sessions — one for newcomers and one for experienced users. You’ll see how recipes work, how to apply them across projects, and how to modernize code with confidence.

Join the next session, bring your questions, and learn how to automate the kind of work that usually eats your sprint time.

Course – Black Friday 2026 – NPI EA – main – before_post_content
announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 4th December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

Course – Black Friday 2026 – NPI – main – before_post_content
announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 4th December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

1. Overview

In our day-to-day work, we often don’t care about JVM’s internal memory allocation.

However, knowing the basics of the JVM memory model comes in handy for performance optimization and improving code quality.

In this article, we’ll explore JVM storage for the static methods and members.

2. JVM’s Memory Classification

Before deep-diving into memory allocation for the static members, we must refresh our understanding of JVM’s memory structure.

2.1. Heap Memory

Heap memory is the runtime data area shared among all JVM threads to allocate memory for all class instances and arrays.

Java classifies heap memory into two categories – Young Generation and Old Generation.

The JVM internally separates the Young Generation into Eden and Survivor Space. Similarly, Tenured Space is the official name of the Old Generation.

The lifecycle of an object in the heap memory is managed by an automatic memory management system known as a garbage collector.

Therefore, the garbage collector can automatically either deallocate an object or move it in the various sections of the heap memory (young to old generation).

2.2. Non-Heap Memory

Non-heap memory consists primarily of a method area that stores class structures, fields, method data, and the code for methods/constructors.

Similar to the Heap memory, all JVM threads have access to the method area.

The method area, also known as Permanent Generation (PermGen), is considered a part of Heap memory, logically, although the simpler implementations of JVM may choose not to garbage-collect it.

However, Java 8 removes the PermGen space and introduces a new native memory space named Metaspace.

2.3. Cache Memory

The JVM reserves the cache memory area for the compilation and storage of native code, such as JVM internal structures and native code produced by the JIT compiler.

3. Static Members Storage Before Java 8

Before Java 8, PermGen stores static members like static methods and static variables. Additionally, PermGen also stores interned strings.

In other words, PermGen space stores the variables and their technical values, which can be primitives or references.

4. Static Members Storage From Java 8 and Beyond

As we’ve already discussed, PermGen space is replaced with Metaspace in Java 8, resulting in a change for memory allocation of the static members.

Since Java 8, Metaspace only stores the class metadata, and heap memory keeps the static members. Furthermore, the heap memory also provides storage for interned strings.

5. Conclusion

In this short article, we explored JVM storage for static members.

First, we took a quick look at the JVM’s memory model. Then, we discussed JVM storage for static members before and after Java 8.

Simply put, we know that the static members were a part of PermGen before Java 8. However, since Java 8, they’re a part of heap memory.

Partner – Moderne – NPI EA (tag=Refactoring)
announcement - icon

Modern Java teams move fast — but codebases don’t always keep up. Frameworks change, dependencies drift, and tech debt builds until it starts to drag on delivery. OpenRewrite was built to fix that: an open-source refactoring engine that automates repetitive code changes while keeping developer intent intact.

The monthly training series, led by the creators and maintainers of OpenRewrite at Moderne, walks through real-world migrations and modernization patterns. Whether you’re new to recipes or ready to write your own, you’ll learn practical ways to refactor safely and at scale.

If you’ve ever wished refactoring felt as natural — and as fast — as writing code, this is a good place to start.

Course – Black Friday 2026 – NPI EA – main – after_post_content

announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 4th December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

Course – Black Friday 2026 – NPI – main – after_post_content

announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 4th December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW