Memory profiling on Linux and macOS with dotMemory 2020.2

Version 2020.2 EAP01 finally brings dotMemory to Linux and macOS! For these systems, dotMemory is currently available only as a command-line tool. The tool is free and lets you take and save memory snapshots. To analyze the snapshots, you still need the standalone version of dotMemory, which is only available on Windows.

What you can profile

Here’s the dotMemory compatibility list for Linux and macOS:

dotMemory compatibility on macOS and Linux

How it is distributed

The command-line tool is distributed in two forms:

  • A .tar.gz archive (macOS | Linux): Download it from the JetBrains website, unpack, and run with the required arguments.
  • A NuGet package at (macOS | Linux): Using this could be more convenient in automation scenarios (e.g. on a CI/CD server): reference the package in your project, and run nuget restore to get the tool on your server.

How to use it

If you have already used the dotMemory command-line profiler on Windows, you will find almost no differences (the only difference is the reduced set of commands, as some types of apps like IIS are not available on Linux and macOS). For those who haven’t, let’s go through the basics.

Get a snapshot of a running .NET Core app

The fastest way to get a snapshot of a running process is to use the get-snapshot command. For example, this command takes gets a snapshot of the process with ID 5589:
./ get-snapshot 5589

Run a .NET Core app under profiling

Note that to perform get-snapshot, dotMemory has to attach to the process, and therefore it has the same limitations as the attach command: it’s applicable only to processes that use .NET Core version 3.0 or later on Linux or .NET 5 on macOS. So, to profile an app that uses .NET Core 2.2 or earlier, you should run this application under profiling with the start-net-core command. For example:
./ start-net-core MyKestrelAspApp.dll

But how can you get snapshots? One of the ways is to send commands to dotMemory’s stdin. For example, to get a snapshot, send:

Running dotMemory on macOS

Another way to get a snapshot is to set a condition for taking the snapshot. This can be great for monitoring applications. For example:

  • ./ start-net-core --trigger-timer=10h MyKestrelAspApp.dll
    This will start MyKestrelAspApp.dll and take snapshots every 10 hours.
  • ./ start-net-core --trigger-mem-inc=50% --trigger-delay=5s MyKestrelAspApp.dll
    This will start MyKestrelAspApp.dll and take snapshots when memory consumption increases by 50% compared to when the profiling session started. The 5-second delay is used to ignore the application’s startup activities.

We invite you to download the tool and try it on Linux and macOS for yourself. As always, your comments are greatly appreciated.

P.S. If you are looking at other possibilities for profiling your code, take a look at dotMemory self-profiling API. It lets you profile your application right from the source code, is distributed as a NuGet package, and works on all platforms.

Comments below can no longer be edited.

13 Responses to Memory profiling on Linux and macOS with dotMemory 2020.2

  1. Avatar

    Alexander Nesterenko says:

    June 10, 2020

    What about the dotMemory unit tests nuget package for macOS and Linux?

    • Alexey Totin

      Alexey Totin says:

      June 15, 2020

      Hi Alexander!
      You mean ‘dotMemory Unit’? There’s no ETA yet, most likely, 2021.

  2. Avatar

    Jun HO says:

    June 11, 2020

    may I know where directory is the memory snapshot file saved?

    • Alexey Totin

      Alexey Totin says:

      June 15, 2020

      by default, it’s the current working directory. will show you the full path to the saved workspace on exit.

  3. Avatar

    Murad says:

    June 16, 2020

    Can not download archive for Linux and macOS.

    {“errors”:[{“code”:404,”message”:”Distribution linux does not exist”}]}

  4. Avatar

    Gregory LEOCADIE says:

    June 24, 2020

    Hi, I took a memory snapshot in a linux container of a .net core application, download the dmw file on my windows workstation.

    But dotMemory (version 2020.2 EAP and the 2020.1.3) failed at opening the file. Can you help me please?

    • Avatar

      Anna says:

      June 25, 2020


      Could you please upload your workspace to our ftp and create support ticket?

      Submit a request:

      • Avatar

        Gregory LEOCADIE says:

        June 25, 2020

        Sure will do.

      • Avatar

        Gregory LEOCADIE says:

        June 25, 2020

        Ok, I did another test (to explain what I did) and I found an issue on my side : The download of the workspace was not complete (even though Chrome displayed it as successful). On the server, the size of the workspace was 9GB. When downloaded and “finished”, the size was 15MB.
        Sorry for the noise.

        And thanks for your amazing tools.

Discover more