Parsing Memory Profile logs (.prfsession)

Use this forum for questions on how to use .NET Memory Profiler and how to analyse memory usage.

Moderator: SciTech Software

Parsing Memory Profile logs (.prfsession)

Postby gvprashanth » Thu Mar 13, 2014 8:48 am


We have automated the memory leak tests, bu we are not able to parse the .prfsession files automatically and send the report.

Please help us in doing the same.

Posts: 1
Joined: Thu Mar 13, 2014 8:46 am

Re: Parsing Memory Profile logs (.prfsession)

Postby Andreas Suurkuusk » Fri Mar 14, 2014 7:36 am

To retrieve data from a session file you need to use the external profiler API. You get access to this API by using the SciTech.NetMemProfiler.Core assembly, which can be found in the "C:\Program files\SciTech\NetMemProfiler4\Assemblies" folder. This API is still not officially documented, but contrary to what is written in another forum post, it is supported. If you need help using the API, you can post a question on this forum (preferred) or send an e-mail to If you use this API, you should be aware that this is the same API that the profiler itself uses, and there may be incompatible changes in later versions (even though we try to avoid it as much as possible).

The code below shows a small example on how you can open a session file and retrieve the compared types.

Code: Select all
using SciTech.Profiler;
using SciTech.Profiler.Memory;
using System;

class Program
    static void Main(string[] args)
        ProfilerApplicationCore application = new ProfilerApplicationCore();

        // Load the session.
        using (ProfilerSession session = application.LoadSession(@"<path to session>"))
            // Retrieve the available snapshots.
            SnapshotHeader[] snapshots = session.SessionFile.GetSnapshotHeaders();

            // Select snapshots. Currently the last two are selected (assuming that
            // at least two snapshots exist)
            SnapshotHeader selectedSnapshot = snapshots[snapshots.Length - 1];
            SnapshotHeader comparisonSnapshot = snapshots[snapshots.Length - 2];

            using (ProfilerComparison comparison = application.CompareSnapshots(
               selectedSnapshot, comparisonSnapshot))
                // Get the compared types from the comparison (if the resource tracker was enabled,
                // GetComparedResources can also be used)
                ComparedTypeInfo[] comparedTypes = comparison.GetComparedTypes();

                // Process the compared types
                // ...

More examples on how to use the API can be found in the following forum posts:

Best regards,

Andreas Suurkuusk
SciTech Software AB
Andreas Suurkuusk
Posts: 995
Joined: Wed Mar 02, 2005 7:53 pm
Location: Sweden

Return to Using .NET Memory Profiler

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

SciTech Software logo

© Copyright 2001-2016. SciTech Software AB
All rights reserved.

SciTech Software AB
Kartvägen 21
SE-175 46 Järfälla


Telephone: +46-706868081