Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Java Memory Management

You're reading from   Java Memory Management A comprehensive guide to garbage collection and JVM tuning

Arrow left icon
Product type Paperback
Published in Nov 2022
Publisher Packt
ISBN-13 9781801812856
Length 146 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Maaike van Putten Maaike van Putten
Author Profile Icon Maaike van Putten
Maaike van Putten
Dr. Seán Kennedy Dr. Seán Kennedy
Author Profile Icon Dr. Seán Kennedy
Dr. Seán Kennedy
Arrow right icon
View More author details
Toc

Table of Contents (10) Chapters Close

Preface 1. Chapter 1: Different Parts of the Java Memory 2. Chapter 2: Primitives and Objects in Java Memory FREE CHAPTER 3. Chapter 3: Zooming in on the Heap Space 4. Chapter 4: Freeing Memory with Garbage Collection 5. Chapter 5: Zooming in on the Metaspace 6. Chapter 6: Configuring and Monitoring the Memory Management of the JVM 7. Chapter 7: Avoiding Memory Leaks 8. Index 9. Other Books You May Enjoy

Preface

Understanding how Java memory works can be of great benefit to your Java coding and application management. It makes it easier to visualize what is going on with object composition and what happens with object allocation and deallocation, combined with object composition. As you are probably aware, object composition is where objects contain other objects. For example, a Person class specifies a property of type Address, which also happens to be a class. Knowing how this all works in memory makes it easier to know what steps to take to get to a certain data field.

Also, the concept of static and accessing the instance using the this keyword will be so much easier to visualize and understand completely when you understand how the memory of Java works. Without understanding how Java memory works, it is impossible to truly grasp the concepts of static and this.

Another advantage of understanding Java memory well is that the difference between using a primitive or a class reference as an argument makes a lot more sense all of a sudden. This also helps with understanding the immutability and mutability of objects.

More complex topics will make more sense too, such as concurrency, one of my personal favorites. This is when multiple things are happening at the same time in your application (multithreading). It’s possible that you haven’t worked with it yet, but as a Java developer, you’ll have to one day. Understanding Java memory makes it easier to understand certain aspects of concurrency, especially data access. Another complex topic that will be easier to understand is garbage collection. This is of crucial importance for performance since it’s a very expensive process, and you want to need it as little as possible and optimize it as much as possible.

Everything that you are probably using on a daily basis already will become clearer when you understand better how Java memory works.

lock icon The rest of the chapter is locked
Next Section arrow right
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at R$50/month. Cancel anytime