Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
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
High Performance with Java

You're reading from   High Performance with Java Discover strategies and best practices to develop high performance Java applications

Arrow left icon
Product type Paperback
Published in Jul 2024
Publisher Packt
ISBN-13 9781835469736
Length 306 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Dr. Edward Lavieri Jr. Dr. Edward Lavieri Jr.
Author Profile Icon Dr. Edward Lavieri Jr.
Dr. Edward Lavieri Jr.
Arrow right icon
View More author details
Toc

Table of Contents (26) Chapters Close

Preface 1. Part 1: Code Optimization FREE CHAPTER
2. Chapter 1: Peeking Inside the Java Virtual Machine 3. Chapter 2: Data Structures 4. Chapter 3: Optimizing Loops 5. Chapter 4: Java Object Pooling 6. Chapter 5: Algorithm Efficiencies 7. Part 2: Memory Optimization and I/O Operations
8. Chapter 6: Strategic Object Creation and Immutability 9. Chapter 7: String Objects 10. Chapter 8: Memory Leaks 11. Part 3: Concurrency and Networking
12. Chapter 9: Concurrency Strategies and Models 13. Chapter 10: Connection Pooling 14. Chapter 11: Hypertext Transfer Protocols 15. Part 4: Frameworks, Libraries, and Profiling
16. Chapter 12: Frameworks for Optimization 17. Chapter 13: Performance-Focused Libraries 18. Chapter 14: Profiling Tools 19. Part 5: Advanced Topics
20. Chapter 15: Optimizing Your Database and SQL Queries 21. Chapter 16: Code Monitoring and Maintenance 22. Chapter 17: Unit and Performance Testing 23. Chapter 18: Leveraging Artificial Intelligence (AI) for High-Performance Java Applications 24. Index 25. Other Books You May Enjoy

Garbage collection

Java developers have long enjoyed the JVM’s ability to manage memory, including allocation and deallocation. The allocation component of memory management is straightforward and not wrought with inherent problems. The area that is most important is freeing previously allocated memory that is no longer needed by the application. This is referred to as deallocation or garbage collection. While not unique to Java programming language, its JVM does a wonderful job with garbage collection. This section takes a detailed look at JVM’s garbage collection.

The garbage collection process

The following example is the creation of two objects, making them reference each other, and then nullifying them both. Once they are nullified, they are no longer reachable, despite that they reference each other. This makes them eligible for garbage collection:

public class Main {
    public static void main(String[] args) {
    ...
lock icon The rest of the chapter is locked
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 $19.99/month. Cancel anytime