NmpCore is standalone tool for collecting snapshots and creating session files on machines where .NET Memory Profiler is not installed. It is useful for gathering memory usage information on production machines, end-user machines, or testing machines.
NmpCore is a free tool that can be downloaded by anyone, it does not require a .NET Memory Profiler license. Additionally, it is a a single file application that does not require any installation.
Note! The session files created by NmpCore can only be opened and analyzed by .NET Memory Profiler Professional, the Standard edition cannot be used.
NmpCore can be started from a command line, using the command:
NmpCore [<options>] <process>
To start NmpCore, the command line must at least specify the process to profiler. It can be specified using the following command line arguments:
Argument | Short form | Description |
---|---|---|
/attach <pid> /attach <process name> |
/a | Attach to a running process. Specify the process using process id or process name, e.g. /a 1234, or /a SomeProcess.exe. Requires that the process runs under .NET Framework 4.0 or later and has concurrent GC disabled. See notes below. |
/program <program name> <args> | /p | Profile a standalone program. This must be the last command line argument to NmpCore, since all additional arguments will be passed to the started program. |
/asp | /asp | Profile an ASP.NET application, hosted by IIS. Using this option will cause NmpCore to stop the IIS service and restart it with profiling enabled. |
/service <service name> | /svc | Profile a Windows Service. Using this option will cause NmpCore to stop the specified service and restart it with profiling enabled. |
Additional command line options can also be included to define the session settings, and to define how snapshots should be collected and how a session file should be created.
Some common options are:
Argument | Short form | Description |
---|---|---|
/collectandstop <count> | /cs | Collects the specified number of snapshots and then stops the profiler. The snapshot collection interval is specified using the /autocollect argument. If the /autocollect argument is not included, the default collection interval of 10 minutes is used. |
/autocollect <interval> | /ac | Enables automatic snapshot collection and sets the collection time interval (in minutes). |
/sessionfile <file path> | /sf | Specifies the name of the session of the session file that shold be created. If no session file name is specified, as Save as window will be shown when the profiling has stopped. |
/peaksnapshot [+/-] | /ps | Enables or disables peak snapshot collection. |
/controlpanel [+/-] | /cp | Shows or hides the NmpCore control panel. The control panel provides a user interface for collecting snapshots manually and for stopping the profiler. It is shown by default unless the /collectandstop argument has been provided. |
/register | /r | Temporarily registers NmpCore. In order to profile a process running under .NET Framework prior to version 4.0 (2.0/3.0/3.5), the profiler has to be registered. This option will cause an elevation prompt if User Access Control is enabled. To prevent the prompt each time NmpCore is run, use the /persistentregister option instead. |
/persistentregister | /pr | Persistent registration of NmpCore. Same as the /register option, but the registraton is not removed when NmpCore exits. Subsequent uses of NmpCore will not require any registration. |
For more information about available command line arguments, see the documentation for .NET Memory Profiler 5.7.
Use the command line below to: attach to a process named SomeProcess.exe, collect a single snapshot and stop profiling, and save the session as C:\Sessions\DumpSession.prfsession.
NmpCore /a SomeProcess.exe /cs1 /sf "C:\Sessions\DumpSession.prfsession"
The response file corresponding to the command line above:
# Attach to process with the name SomeProcess.exe (short form /a)
/attach SomeProcess.exe
# Collect a single snapshot and stop profiler (short form /cs)
/collectandstop
# Save session as DumpSession.prfsession (short form /sf)
/sessionfile c:\Sessions\DumpSession.prfsession
Another possibility is to collect a few snapshots in the same session file. Use the command line below to:
NmpCore /a SomeProcess.exe /cs3 /ac5 /sf "C:\Sessions\DumpSession.prfsession"
A similar command line can also be used even when starting the program from NmpCore. Note that the /p argument must come last.
NmpCore /cs3 /ac5 /sf "C:\Sessions\DumpSession.prfsession" /p <path>\SomeProcess.exe
In order for the NmpCore tool to attach to a process, the process must be running under .NET Framework 4.0 or later. Additionally, unless .NET Framework 4.5 or later is installed, the concurrent garbage collector must not be enabled. This is normally not a problem when attaching to server processes like ASP.NET running under IIS, since they are using the server garbage collector. For a standalone program, the concurrent garbage collector can be disabled by modifying the application config file. To disable concurrent GC and run the program under .NET Framework 4.0, modify the config file so that it includes the following settings:
<?xml version="1.0"?>
<configuration>
<runtime>
<gcConcurrent enabled="false" />
</runtime>
<startup>
<supportedRuntime version="v4.0.30319" />
</startup>
</configuration>
NmpCore.exe
(9,293 KB, v5.7.28, February 8, 2023)
The following NuGet packages related to automated memory testing using .NET Memory Profiler are available: