This book recently co-authored by my friend and colleague, Maaike van Putten, may prove useful:
"
Java Memory Management" by Maaike van Putten | Sean Kennedy (2022 Packt Publishing)
Here's the Table of Contents for those that may be interested:
Table of Contents
Preface
1
Different Parts of the Java Memory
Technical requirements
Understanding computer memory and Java memory
Computer memory
Accessing the main memory
Overview of the main memory
Java memory and the JVM
The JVM
Memory management and the JVM
Memory management before Java
Understanding the JVM’s components for memory management
Runtime data area
Creating variables in Java
Primitives and reference types
Storing variables on the stack
Current frame and current method
Elements of the frame
Values on the stack
Primitives and wrapper classes
Creating objects in Java
Storing objects on the heap
Exploring the Metaspace
Summary
2
Primitives and Objects in Java Memory
Technical requirements
Understanding primitives on the stack and heap
Storing objects on the heap
References
Objects
Understanding the differences between references and objects
Managing object references and security
Inspecting the escaping references issue
Summary
3
Zooming in on the Heap Space
Exploring the different generations on the heap
Garbage collection roots
Learning how the spaces are used
Understanding the minor garbage collection algorithm
Demonstrating the minor garbage collection algorithm in action
Summary
4
Freeing Memory with Garbage Collection
Technical requirements
Being eligible for GC
Marking by the garbage collector
Stop-the-world
Reference counting and islands of isolation
Sweeping by the garbage collector
Normal sweeping
Sweeping with compacting
Sweeping with copying
Exploring GC implementations
Generational GC
Serial GC
Parallel GC
CMS GC
G1 GC
Z GC
Monitoring GC
Summary
5
Zooming in on the Metaspace
JVM usage of the Metaspace
Class loading
Releasing Metaspace memory
Metaspace runs out of memory
Metaspace size exceeds a JVM-set threshold
Garbage collection of the Metaspace
Summary
6
Configuring and Monitoring the Memory Management of the JVM
Technical requirements
The basics of JVM tuning for memory management
Obtaining relevant metrics for memory management
Well-functioning memory
Normal latency
Level of throughput
Profiling Java applications
Profiling with jstat and jmap
Profiling with VisualVM
Tuning the configurations of the JVM
Tuning the heap size and thread stack size
Logging low memory
Tuning the Metaspace
Garbage collection tuning
7
Avoiding Memory Leaks
Technical requirements
Understanding memory leaks
Spotting memory leaks
Heap memory footprint
Garbage collector activity
Heap dump
Avoiding memory leaks
Common pitfalls and how to avoid them
Summary
Java Memory Management
Maaike van Putten | Sean Kennedy