How-To's

Console Profiler replaces Remote Profiling in dotMemory 2019.2

dotMemory 2019.2 no longer supports remote profiling. Remote profiling allowed you to profile an application running on a remote computer with dotMemory running locally. So, why did we get rid of it?

First, our statistics showed that the user base of the feature was vanishingly small. Not least because of the fact that remote profiling requires some effort from an end-user. You have to launch the remote agent on a remote machine, make sure that the agent is not blocked by a firewall, and so on. This presents certain challenges, especially in production environments.

Second, we believe that the dotMemory console profiler is a better choice for profiling on a remote computer. The process doesn’t require that much preparation and is easily reproducible (you create one batch script and use it anytime).

Before 2019.2, the console profiler could not fully replace the standalone dotMemory as it lacked support for many application types. The 2019.2 release has fixed this issue by adding separate commands for all kinds of applications:

  • get-snapshot – for attaching to a running .NET application and getting a single snapshot.
  • attach – for attaching to a running .NET application and getting any number of snapshots.
  • start – for starting a standalone .NET application under profiling.
  • start-netcore – for a .NET Core application.
  • start-iis – for (re)starting IIS under profiling.
  • start-iis-express – for an IIS Express–hosted web application.
  • start-windows-service – for (re)starting a managed Windows service under profiling.
  • start-wcf-service – for a WCF host with a specified WCF Service Library.
  • start-winrt – for a WinRT application.
  • profile-new-processes – for profiling any managed application that is launched after this command.

To use the console profiler, first, you need to download it. It’s worth noting that the tool is distributed free of charge and does not require any licenses to run.

Getting the console profiler

  1. Download a .zip file with the console profiler from our download page.
  2. Unzip the file on the remote computer.

Actually, that’s it – you’re ready to go! If you prefer NuGet, you can download the corresponding package.

Getting snapshots instantly

The most typical scenario is that some application has a memory problem and you want to instantly get a memory snapshot. For example, there’s an already running application with PID=1234 (it could be a standalone .NET / .NET Core application, IIS server, or a service).

To get a snapshot, run:
dotMemory.exe get-snapshot 1234

If you don’t know the PID but know the name (say, MyApp), run:
dotMemory.exe get-snapshot MyApp --all

Note the --all option at the end. If there’s more than one MyApp process, dotMemory will take a snapshot of each process.

Monitoring applications

Sometimes, you need to track application memory consumption over a long time interval. In this case, you can start or attach to your application under profiling and get snapshots only if a particular condition is satisfied, that is, if a periodic time interval ends, or memory consumption increases by a specified value.

For example, if you want to profile some myapp web app running on IIS server and take snapshots every 5 hours:
dotMemory.exe start-iis --trigger-timer=5h --open-url=localhost/myapp --use-browser=Chrome

Or, for example, if you want to take snapshots only when memory consumption increases by 50%:
dotMemory.exe start-iis --trigger-mem-inc=50% --open-url=localhost/myapp --use-browser=Chrome

Getting snapshots when you want

Sometimes, it’s necessary to have direct control over the profiling process; for example, you need to get a snapshot at some exact moment by a direct command. This can be done by sending special messages to stdin of dotMemory.exe.

Suppose we want to profile some IIS Express-hosted application with a configuration file. Follow these steps:

  1. Start a profiling session:
    dotMemory start-iis-express --service-output --config=.idea\config\applicationhost.config --site=MyWebApp
    Note the --service-output argument. It tells dotMemory to send service messages to stdout, like
    ##dotMemory["connected"]
  2. When you want to take a snapshot, send the following command to stdin:
    ##dotMemory["get-snapshot"]
    After the snapshot is taken, dotMemory will send the following to stdout:
    ##dotMemory["workspace-saved", {path: "..."}]

In this post, we’ve just touched on some of the console profiler’s capabilities. For more information about the tool, please refer to our online documentation or the console profiler’s built-in help:
dotMemory.exe help

To test the updated dotMemory console profiler in action, download it using this link. Note that to examine the snapshots collected by the console profiler, you should use the standalone version of dotMemory.

We’d love to hear your feedback about the console profiler!

image description