26,39 €
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.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 164
Veröffentlichungsjahr: 2022
A comprehensive guide to garbage collection and JVM tuning
Maaike van Putten
Seán Kennedy
BIRMINGHAM—MUMBAI
Copyright © 2022 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Group Product Manager: Gebin George
Publishing Product Manager: Kunal Sawant
Senior Editor: Rounak Kulkarni
Technical Editor: Jubit Pincy
Copy Editor: Safis Editing
Language Support Editor: Safis Editing
Project Coordinator: Deeksha Thakkar
Proofreader: Safis Editing
Indexer: Hemangini Bari
Production Designer: Shankar Kalbhor
Developer Relations Marketing Executive: Sonakshi Bubbar
Business Development Executive: Kriti Sharma
First published: November 2022
Production reference: 1281022
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-80181-285-6
www.packt.com
To my students and my teachers.
– Maaike van Putten
To my wife, Maria, and my daughters, Emily, Miriam, and Lilian.
– Seán Kennedy
Maaike van Putten is an experienced software developer and trainer with a passion for software development and helping others to get to the next level in their career. Some of her favorite languages are Java, JavaScript, and Python. She participates as a developer in software development projects and teaches a lot of training courses, ranging from IT for beginners to advanced topics for senior software developers. She also loves to create online content to help a larger audience, and she does so for diverse platforms such as Pluralsight, LinkedIn Learning, and Udemy.
I want to thank my students, my teachers, my friends, and my family for always supporting me.
Seán Kennedy is a university lecturer with over 20 years of experience in teaching. He has a PhD in IT and is Oracle-certified in Java at the Professional level (OCP). In his daily work, he teaches Java on a bespoke master’s program for a highly regarded software company. He has a YouTube channel called Let’s Get Certified that teaches Java at all levels and prepares candidates for Java certification. He also has similar courses on Udemy. Outside of work, he enjoys tennis, walking, nature, reading, and TV.
I want to thank the people who have always supported me, especially my wife, Maria, and my late parents.
Himanshu Agrawal is an industry veteran with close to 13 years of experience in designing and implementing solutions in JEE technologies. Currently, he works as an Associate Consultant with CGI, with whom he has been associated for close to 13 years. Himanshu specializes in niche technical areas like JVM, Multithreading, TLS, and Apache HTTPD. He is an Oracle Certified Java Dev, Oracle Certified Web Component Dev and certified by Google Cloud in Architecting with Google Kubernetes Engine. Moreover, he is a Certified SAFe 5 Practitioner and has done certificate courses from top universities like Harvard (via HarvardX) and MIT (via MITx). Himanshu extends his technical expertise to teams primarily in BFSI and Telecom sectors.
Silviu Turuga is an IT professional who has worked for almost 20 years for different companies around the world. During this time, he has performed various roles, from technical support, software development, and technical team lead to DevOps and DevSecOps. He has used many different programming languages and frameworks. Silviu is an Oracle Certified Professional for Java 8. He loves to see everything as a challenge that has to have a solution. He is an active team player, willing to share his knowledge with others, and also enjoys mentoring. During his free time, he likes to perform home automation and play with IoT devices.
Do you know the phenomenon of having to restart an application to boost the performance of that application? If so, you may have experienced the outcome of poor memory management: the memory getting full and the application slowing down. This is not always why applications slow down – other causes such as processing data from a server or a bottleneck in the network, among other things, play a role – but memory management problems are a usual suspect of degrading application performance.
You’ve probably heard of memory in the field of computer science before. That makes sense because computers have memory and they use this memory to store and access data while running programs (which in their turn are data too!).
So, when does an application use memory? Well, for example, let’s say you’d like to run an application that is going to process a huge video file. If you do this with your activity monitoring application (for example, Activity Monitor on macOS or Task Manager on Windows) open, you’ll see that the used memory increases once you open the application and load the video. Memory is a finite resource on your computer and once your computer runs out of it, it becomes slow.
There are many ways to improve the performance of an application. A deeper understanding of how exactly this memory works is one of the ways that could help you improve the performance of your applications. Memory that is used efficiently by using good practices in coding is going to boost the performance of your application. So, coding well and being mindful of how the memory works should always be the first way to achieve high performance when it comes to memory management. There is another way in which Java memory management can be influenced and that is by configuring the Java Virtual Machine (JVM), which takes care of the Java memory. This is something that we’ll cover in Chapter 6 when we’re ready for it.
The efficient handling of Java memory is of crucial importance for the performance of a Java application. In Java, this is especially the case because it comes with expensive processes such as garbage collection, which again, we’ll see later after gaining enough basic knowledge to comprehend it.
Memory management is