Tactic 4: Identifying by swprofiler | Tactic 5: Performing the heap dump


Tactic 4: Tuning the cache size


+

Search Tips   |   Advanced Search

If the free space after GC declines with no growing AF, then most likely cache tuning is causing the memory problems. Caching does not necessarily mean DynaCache. It includes other types of cache that are being used. One solution is reducing the in-memory cache size and letting the overflow entries use the disk cache if possible.

IBM recommends having 40% of JVM free after caching is enabled.

Sometimes an excessive number of cache objects look like a memory leak since the cache grows as the application receives an increasing load. Customers and testers need to find a stabilization point where the system does not generate OutOfMemory errors due to too many cached objects. Tune the cache size according to how much heap size is being used. In Figure 24-13, the example shows an OutOfMemory exception. After further examination, you see that the cached page is 60-100 KB in size and the number of cache entries is set to 5000. Therefore, half of this 1 GB heap is allocated to the cache.

Note: A quick way to rule out caching, such a Dynamic Caching, concerns that may work for you is to try turning-off Dynamic Caching altogether, to force disk caching, or to keep all cached objects in memory. The behavior of your application under such circumstances may reveal whether caching policies or disk offload may be contributing to your caching concerns.

Note, however, that this trial-and-error approach may change your application's error path and thus deviate from your error-causing scenarios.

In most cases, you can adjust the DynaCache size to eliminate such problems.

To tune the DynaCache size:

  1. Log in to the WebSphere Application Server administrative console.

  2. Expand...

    Servers | Application servers | server1 | Container Services | Dynamic Cache Service | Cache size

  3. Set the value of the cache size that you want.

  4. Save your changes and restart the application server.

Figure 24-15 shows the memory usage of the same test case after tuning the number of cache entries to 3000, and enabling the disk offload to let the overflow entries use the disk cache. The application has stabilized at 100 MB free space in the heap after three times the duration of the first test where the OutOfMemory exception was encountered. From Figure 24-15, you can see at the beginning the cache is warming up, causing a drop in free space. However, towards the end of the free space, the cache is stabilizing, which means that it is now fully warmed.