This page describes how to monitor custom memory structures for Java. 

AppDynamics automatically tracks long-lived Java collections (HashMap, ArrayList, and so on) with Automatic Leak Detection. To track specific classes, you can use the Custom Memory Structures capability in the Controller UI.

You can use this capability to monitor a custom cache or other structure that is not a Java collection. For example, you may have a custom cache or a third-party cache such as Ehcache. In a distributed environment, caching can easily become a prime source of memory leaks. In addition, custom memory structures may or may not contain collections of objects that would be tracked using automatic leak detection. 

Monitoring custom memory structures with the Java Agent can result in increased CPU utilization. AppDynamics recommends you enable memory structure monitoring on a short-term basis only while troubleshooting or in pre-production environments.

To configure custom memory structures, ensure custom memory structures are supported in your JVM environment. See JVM Support.

  • To activate or deactivate object instance tracking, you need the Configure Agent Properties permission.
  • To configure the custom classes to track, you need the Configure Memory Monitoring permission. See Manage Custom Roles.

Custom Memory Structures and Memory Leaks

Typically custom memory structures are used as caching solutions. In a distributed environment, caching can easily become a source of memory leaks. AppDynamics helps you to manage and track memory statistics for these memory structures.

AppDynamics provide visibility into:

  • Cache access for slow, very slow, and stalled business transactions.
  • Usage statistics rolled up to the Business Transaction level.
  • Keys being accessed.
  • Deep size of internal cache structures.

Automatic Leak Detection Versus Monitoring Custom Memory Structures

Automatic leak detection captures memory usage data for all map and collection libraries in a JVM session. However, custom memory structures may not contain all collection objects. For example, you may have a custom cache or a third-party cache such as Ehcache for which you want to collect memory usage statistics.

Using custom memory structures, you can monitor any custom object created by the app and the size data can be traced across JVM restarts. Automatic leak detection is typically used to identify leaks, while custom memory structures are used to monitor large coarse-grained custom cache objects.

The following provides the workflow for configuring, monitoring, and troubleshooting custom memory structures. You must configure custom memory structures manually.

  1. On the Tiers & Nodes dashboard, use the Automatic Leak Detection, On Demand Capture Session feature to determine which classes aren't being monitored, for example, custom or third-party caches such as EhCache.
  2. Configure Custom Memory Structures and then restart the JVM if necessary. 
  3. Enter the fully-qualified classname on the Create New Instance Tracker window and click Save.
    AppDynamics automatically tracks long-lived Java collections (HashMap, ArrayList, and so on) with Automatic Leak Detection.
  4. Turn on Custom Memory Structures monitoring to detect potential memory leaks in the custom memory structures you have configured.
  5. Drill down into leaking memory structures for details that will help you determine where the leak is.

To identify custom memory structures:

  1. Navigate to MemoryAutomatic Leak Detection and click On.
  2. Click Start On Demand Capture Session to capture information on which classes are accessing which collections objects. Use this information to identify custom memory structures.

AppDynamics captures the top 1000 classes, by instance count.

Identify Potential Memory Leaks

Start monitoring memory usage patterns for custom memory structures. An object is automatically marked as a potentially leaking object when it shows a positive and steep growth slope. The Memory Leak dashboard provides the following information:

  • Heap & Garbage Collection—Provides heap and garbage collection metrics.
  • Automatic Leak Detection—Provides memory usage data for all map and collection libraries in a JVM session.
  • Object Instance Tracking—Provides tracking data for the top 20 application and top 20 system (core Java) classes in the heap.
  • Custom Memory Structures—Allows you to track specific classes and monitor a custom cache or other structure that is not a Java collection.

The Custom Memory Structures dashboard provides the following information:

    • Class—The name of the class or collection being monitored.
    • Deep Size (bytes)—The upper boundary of memory available to the structure. The deep size is traced across JVM restarts
    • % of Current Used Heap—The percentage of memory available for dynamic allocation.
    • Potentially Leaking—Potentially leaking collections are marked as red. We recommend that you start a diagnostic session on potentially leaking objects. 
    • JVM Start Time—Custom Memory Structures are tracked across JVM restarts. 
    • Status—Indicates if a diagnostic session has been started on an object.
    • Deep Size—A positive and steep growth slope indicates a potential memory leak.

After the potentially leaking collections are identified, start the diagnostic session.

Diagnose Memory Leaks

On the Custom Memory Structures dashboard, select the class name to monitor and click Drill Down.

Isolate Leaking Collections

Use Content Inspection to identify to which part of the application the collection belongs. It allows monitoring histograms of all the elements in a particular memory structure. Start a diagnostic session on the object and then follow these steps:

  1. Select the Content Inspection tab.
  2. Click Start Content Summary Capture Session.
  3. Enter the session duration. Allow at least 1-2 minutes for the data to generate.
  4. Click Refresh to retrieve the session data.
  5. Click a snapshot to view the details about that specific content summary capture session.

Access Tracking

Use Access Tracking to view the actual code paths and business transactions accessing the memory structure. Start a diagnostic session on the object and then follow these steps:

  1. Select the Access Tracking tab.
  2. Select Start Access Tracking Session.
  3. Enter the session duration. Allow at least 1-2 minutes for data generation.
  4. Click Refresh to retrieve the session data.
  5. Click a snapshot to view the details about that specific content summary capture session.