Book Image

Java 9 Cookbook

By : Mohamed Sanaulla, Nick Samoylov
Book Image

Java 9 Cookbook

By: Mohamed Sanaulla, Nick Samoylov

Overview of this book

<p>Java is an object-oriented programming language. It is one of the most widely accepted languages because of its design and programming features, particularly in its promise that you can write a program once and run it anywhere.</p> <p>This cookbook offers a range of software development examples in simple and straightforward Java 9 code, providing step-by-step resources and time-saving methods to help you solve data problems efficiently. Starting with the installation of Java, each recipe addresses a specific problem, with a discussion that explains the solution and offers insight into how it works.</p> <p>We cover major concepts such as Project Jigsaw and various tools that will enable you to modularize your applications. You will learn new features in the form of recipes that will make your applications modular, secure, and fast.</p>
Table of Contents (22 chapters)
Title Page
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Some best practices for better memory usage


Memory management may never become an issue for you, or it can be a haunting never-ending story of your life, and anything in between. It is probably going to be a non-issue for a majority of programmers, especially with the constantly improving garbage collection algorithms. The G1 garbage collector (default in JVM 9) is definitely a step in the right direction. But there is also a chance you will be called (or will notice yourself) about the degrading application performance, and that is when you'll learn how well you are equipped to meet the challenge.

This recipe is an attempt to help you avoid such a situation or to get out of it successfully.

How it  works...

The first line of defense is the code itself. In the previous recipes, we have already discussed the need to release resources as soon as they are not needed anymore and the usage of StackWalker to consume less memory. There are plenty of recommendations on the internet, but they might...