cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

This product reached the end of support date on March 31, 2021.

.NET application memory leak analysis

aniket_dixit
Newcomer

    Hi,

    To analyze memory leak issue for .NET application, I am
    following approach explained in ‘Memory diagnostics for Java & .NET’ video
    tutorial by Andy.

    Followed process is as below-

    • 1.To check out memory leak issue, we took 6 ‘Diagnose Runtime > Total Memory >
      Create Memory Snapshot > Memory Consumption Trending’
      snapshots with
      5min time interval between each snapshot.

    From Memory Usage Trend, we observed that
    almost ~400 MB memory is getting leaked.

    • 2.To find out details of memory leaks, we did
      comparison of trending snapshots to check out ‘Instance Count, GC Size’-
    • 3.Moving ahead, we took ‘Diagnose Runtime >
      Total Memory > Create Memory Snapshot > Deep Memory Leak Analysis’
      snapshot to find classes, object and references to search large objects and
      their keeping alive paths.

    • By getting details for
      System.Data.DataColumn we found object details of that class, as below-
    • To further drill down to get details of
      object, we explore particular object –
    • In ‘Deep Memory Leak Analysis’ snapshot we
      searched for class which was showing high number of instances and large GC Size
      in ‘Memory Consumption Trending’
      comparison. Below image shows the captured details -
    • To drill down this information further, can
      we get details of objects consuming memory and the
      class / method name where the objects are referred?

    • 4.To find method details, we analyzed ‘Methods’
      which were active when Total Memory snapshots taken. However we cannot conclude
      more details for memory details of particular objects, classes and methods.

    • 5.Post studying, all the information available in
      documents, forum to sort required details; we created Memory Sensors for eNSRC method and placed it across
      respective agents to capture memory details however we could retrieve –

    • Type | Class | Instances | Allocating Class | Allocating Method | File
      | Line | Agent

    With this approach, details about
    memory used by particular objects and referring class, methods are still unavailable
    to us which can be hand over to developers to amend certain code, so that
    memory leak issue will be resolved, please let me know how can that details be
    traced?

    Or is there any other way to find
    same details? Please assist to sort out this requirement.

    @agrabner

    4 REPLIES 4

    Joe_Hoffman
    Dynatrace Leader
    Dynatrace Leader

    Aniket, Thanks for that detail.

    In step 1, i'm not sure i see a pattern of a memory leak, as it appears the total memory consumed did not grow. Perhaps you need to take snapshots across a larger timeframe more than 25 minutes?

    The rest of the methodology steps depend on the type of problem you are chasing, whether it is a leak or perhaps simply excessive object creation/destruction, or possibly simply too many large objects, but stable. Perhaps I misunderstood why you concluded you have a memory leak, which is normally observable by continually increasing level of memory consumption.

    hth

    joe Hoffman

    Thanks Joseph.

    In that case I have to follow 'simply excessive object creation/destruction, or possibly simply too many large objects, but stable' scenario which you have mentioned. So, prospective to this scenario; can I trace down details of memory used by particular objects and referring class, methods?

    Thanks,

    Aniket

    Aniket, Excessive GC activity would indicate that you have excessive object creation/destruction events. But there's no screenshots indicating excessive GC, so I don't know.

    To pursue the Too Many Large Object theory, I would expect your heap to be excessively large, but it does not seem excessive. However I don't know your expectation. But to pursue this type of problem I would inspect the Instance Count and GC Size columns. But be careful as an object such as String is not necessarily your problem but perhaps it's the object that itself contains strings. So this is where it can be helpful to look at the Keep Alive paths and see why you have so many String objects. Perhaps String is a child object of Address which is a child object of Person and theres a Collection of Person objects that's being kept alive unnecessarily. Hopefully this makes sense.

    -joe

    andreas_grabner
    Dynatrace Guru
    Dynatrace Guru

    I agree with Joe. There doesnt seem to be a real memory leak. You should try to run longer tests and take more snapshots. You can also try to run the snapshots with the option "Force GC" so that you really only get to see objects that remain on the heap -> that would make it easier to hunt real memory leaks.

    if you want to find out where certain objects get allocated simply create Memory Sensor Rules for those objects that you want to trace back to a PurePath. Just be careful to pick objects that are not getting created in the millions, e.g: String objects.

    Andi