Memory leak ArrayList java

  • AppDynamics Documentation 21.4
  • Application Monitoring
  • Tiers and Nodes
  • Monitor JVMs
  • Current: Custom Memory Structures for Java

Custom Memory Structures for Java

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

  • To activate or deactivate object instance tracking, you need theConfigure Agent Propertiespermission.
  • To configure the custom classes to track, you need theConfigure Memory Monitoringpermission. SeeCreate and 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 clickSave.
    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 Memory >Automatic Leak DetectionandclickOn.
  2. ClickStart On Demand Capture Sessionto 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 Leakdashboard provides the following information:

  • Heap & Garbage CollectionProvides heap and garbage collection metrics.
  • Automatic Leak DetectionProvides memory usage datafor all map and collection libraries in a JVM session.
  • Object Instance TrackingProvidestracking data for thetop 20 application and top 20 system [core Java] classes in the heap.
  • Custom Memory StructuresAllows 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:

    • ClassThe 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 HeapThe percentage of memory available for dynamic allocation.
    • Potentially LeakingPotentially leaking collections are marked as red. We recommend that youstart a diagnostic sessionon potentially leaking objects.
    • JVM Start TimeCustom Memory Structures are tracked across JVM restarts.
    • StatusIndicates if a diagnostic session has been started on an object.
    • Deep SizeA 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 clickDrill 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 theContent 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. SelectStart Access Tracking Session.
  3. Enter the session duration. Allow at least 1-2 minutes for data generation.
  4. Click Refreshto retrieve the session data.
  5. Click a snapshot to view the details about that specific content summary capture session.

Video liên quan

Chủ Đề