CHAPTER 12 TRENDING, (Personal web server) FORECASTING, AND CAPACITY PLANNING

CHAPTER 12 TRENDING, FORECASTING, AND CAPACITY PLANNING Heap Usage Patterns Throughout this book I have been emphasizing the importance of heap tuning: your application runs inside your heap, and a poorly tuned heap can destroy the performance of your application. Therefore, generating a profile of your heap behavior and performing a trend analysis on its behavior are important. Remember that the behavior and tuning of your heap are directly related to your usage patterns: changes in usage patterns may necessitate a retuning of the heap. The heap trend analysis that we perform includes the following: Heap configuration behavior Memory leaks Heap configuration behavior includes both heap utilization and garbage collection behavior. Every application has a certain number of objects that it needs to maintain in memory to support its user load. This includes pooled and cached items as well as user session information. Your goal under normal load is to maintain a heap utilization of about 70 percent. This percentage provides you with enough memory to support peaks in usage but not so much that its size burdens garbage collection. Garbage collection behavior tracking includes the frequency, type, and duration of garbage collections. You want to know how frequently stop-the-world garbage collections run and how long they take. Furthermore, you want to know how frequently minor collections run and how effective they are (for example, how much memory are they able to reclaim?). When you know the current heap utilization and the frequency and duration of each type of garbage collection, the next step is to analyze the historical performance of these metrics to identify trends. For example, three months ago the heap was at 65 percent utilization, but today it is at 80 percent utilization. Furthermore, major garbage collections were running every 30 minutes, and now they are running every 15 minutes. The pattern between these changes has been a steady linear growth in proportion to an increase in user load. In this scenario, user load has added additional overhead on the heap, and the heap needs to be resized and potentially retuned. Proactive attention to heap configuration trends can mitigate many performance problems. Your proactive analysis needs to be performed frequently and methodically. A memory leak is one of the biggest problems in Java EE applications. Java s garbage collection eliminates standard C++-style memory leaks caused by allocating and dereferencing memory: the garbage collector reclaims all memory that has been dereferenced when it needs additional memory. Because all Java object variables are created on the stack and reference physical objects on the heap, each object has a reference count associated with it. When its reference count reaches zero, the object can be reclaimed by the garbage collector. However, if you are maintaining an inadvertent reference to an object, then the garbage collector cannot free it. One of the biggest causes of memory leaks in Java is the misuse of Java Collections classes. A Collections class is a data structure that acts as a container for objects and, as such, defines a reference to each object. Programmers commonly retrieve an object from a Collections class, use it, and discard it when finished, thinking that the object can be garbage collected. But because they did not explicitly remove the object from the Collections class, the Collections class continues to maintain a reference to the object. In this scenario, a lingering reference to the object remains, and its memory cannot be reclaimed until the object is explicitly removed from the Collections class. Figure 12-1 illustrates this lingering object reference graphically.
Go visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.

Leave a Reply