Java Memory Management: A comprehensive guide to garbage collection and JVM tuning
- Length: 146 pages
- Edition: 1
- Language: English
- Publisher: Packt Publishing
- Publication Date: 2022-11-25
- ISBN-10: 1801812853
- ISBN-13: 9781801812856
- Sales Rank: #0 (See Top 100 Books)
Improve application performance by tuning, monitoring and profiling both the garbage collector and JVM
Key Features
- Understand the different parts of Java memory and the various garbage collectors so you can select your preferred one
- Explore how memory management can help to effectively improve performance
- Learn how to spot and avoid memory leaks to enhance application performance
Book Description
Understanding how Java organizes memory is important for every Java professional, but this particular topic is a common knowledge gap for many software professionals. Having in-depth knowledge of memory functioning and management is incredibly useful in writing and analyzing code, as well as debugging memory problems. In fact, it can be just the knowledge you need to level up your skills and career.
In this book, you’ll start by working through the basics of Java memory. After that, you’ll dive into the different segments individually. You’ll explore the stack, the heap, and the Metaspace. Next, you’ll be ready to delve into JVM standard garbage collectors. The book will also show you how to tune, monitor and profile JVM memory management. Later chapters will guide you on how to avoid and spot memory leaks.
By the end of this book, you’ll have understood how Java manages memory and how to customize it for the benefit of your applications.
What you will learn
- Understand the schematics of debugging and how to design the application to perform well
- Discover how garbage collectors work
- Distinguish between various garbage collector implementations
- Identify the metrics required for analyzing application performance
- Configure and monitor JVM memory management
- Identify and solve memory leaks
Who this book is for
This book is for all levels of Java professionals, regardless of whether you’re a junior or senior developer, a DevOps engineer, a tester, or the system admin of a Java application. If you currently don’t have in-depth knowledge of Java memory, garbage collection, and/or JVM tuning, then this book will help you to take your Java skills to the next level.
Cover Title Page Copyright and Credit Dedicated Contributors Table of Contents Preface Chapter 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 Chapter 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 Chapter 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 Chapter 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 Chapter 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 Chapter 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 Chapter 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 Index Other Books You May Enjoy
Donate to keep this site alive
How to download source code?
1. Go to: https://github.com/PacktPublishing
2. In the Find a repository… box, search the book title: Java Memory Management: A comprehensive guide to garbage collection and JVM tuning
, sometime you may not get the results, please search the main title.
3. Click the book title in the search results.
3. Click Code to download.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.