Page 1 of 1
Parsing Memory Profile logs (.prfsession)
Posted: 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.
Re: Parsing Memory Profile logs (.prfsession)
Posted: 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 firstname.lastname@example.org
. 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
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(
// 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: