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.
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...