API: write dump/session to disk?
API: write dump/session to disk?
I've been using .NET Memory Profiler to significantly cut down on memory leaks due to non-disposed objects, stray event handlers, etc. Very nice.
Now, I have a customer with a memory issue I've failed to reproduce, and I'm considering embedding the SciTech.MemProfilerApi library in the shipping application in order to help track this down. (I think this is covered by the professional license?)
As such, I thought I could start with a button that takes a memory snapshot* and saves the result to disk, presumably using the .prfsession format. However, while NmpCore can apparently do this from the command-line (while also providing some form of UI), such functionality appears missing in the API. Is this not (yet?) a supported scenario, or am I approaching this wrong?
Should I instead ship NmpCore with the app, and make a button that launches it?
*) Comparison snapshots, etc. will be interesting for later, but for now, I'm mostly just interested in browsing through what instances currently exist.
Now, I have a customer with a memory issue I've failed to reproduce, and I'm considering embedding the SciTech.MemProfilerApi library in the shipping application in order to help track this down. (I think this is covered by the professional license?)
As such, I thought I could start with a button that takes a memory snapshot* and saves the result to disk, presumably using the .prfsession format. However, while NmpCore can apparently do this from the command-line (while also providing some form of UI), such functionality appears missing in the API. Is this not (yet?) a supported scenario, or am I approaching this wrong?
Should I instead ship NmpCore with the app, and make a button that launches it?
*) Comparison snapshots, etc. will be interesting for later, but for now, I'm mostly just interested in browsing through what instances currently exist.
Re: API: write dump/session to disk?
Never mind; I think I understand now. Starting the profiling session at all isn't actually supported by the API; rather, I need to initiate it from either the full NMP app, or NmpCore. Right?
-
- Posts: 1030
- Joined: Wed Mar 02, 2005 7:53 pm
Re: API: write dump/session to disk?
Yes, you are correct. The profiler API is intended to control the profiler from within the profiled process, it cannot be used to initiate profiling by itself.
There's an external API that can be used, but this API requires the full profiler to be installed on the machine which I assume will not work for you, since you want to create sessions on a customer's machine.
Triggering NmpCore as an external process can be solution, e.g. by using something like:
Note that as long as you only collect a single snapshot, the information available will be almost the same as if you create a memory dump file and then import it into the profiler. A memory dump file may be easier to create, since it does not require NmpCore on the customer's machine, but the file will be bigger than a session file, and if you want to collect more than one snapshot, it will not support instance tracking.
There's an external API that can be used, but this API requires the full profiler to be installed on the machine which I assume will not work for you, since you want to create sessions on a customer's machine.
Triggering NmpCore as an external process can be solution, e.g. by using something like:
Code: Select all
Process.Start( "NmpCore", "/a:<my pid> /ac1 /cs /sf \"<path to session file>\"");
Best regards,
Andreas Suurkuusk
SciTech Software AB
Andreas Suurkuusk
SciTech Software AB
Re: API: write dump/session to disk?
Is it recommended to collect more than one snapshot btw, Andreas?
-
- Posts: 1030
- Joined: Wed Mar 02, 2005 7:53 pm
Re: API: write dump/session to disk?
Yes, it is normally recommended to collect more than one snapshot. This way you can more easily identify memory usage trends, e.g. see if there are types with additional instances in each new snapshot. With instance tracking enabled, you will also see the specific instances that are new in each snapshot.
Best regards,
Andreas Suurkuusk
SciTech Software AB
Andreas Suurkuusk
SciTech Software AB
Who is online
Users browsing this forum: No registered users and 24 guests