In Chapter 2, Understanding Java Fundamentals, we have seen the continuous and tremendous effort to enhance and optimize the JVM garbage collector. In spite of all this great effort put into the allocated and free memory in an optimized way, we still see memory issues in Java Enterprise applications mainly due to the way people are dealing with memory in these applications.
We will discuss mainly three types of memory issues: memory leakage, memory allocation, and application data caching.
Memory leakage is a common performance issue where the garbage collector is not at fault; it is mainly the design/coding issues where the object is no longer required but it remains referenced in the heap, so the garbage collector can't reclaim its space. If this is repeated with different objects over a long period (according to object size and involved scenarios), it may lead to an out of memory error.
The most common example of memory leakage is adding objects to...