Search code examples
c#asp.net-core.net-5memory-profilingdotmemory

Start memory profiling of .NET Core app using dotMemory command line profiler


I am trying to do some memory profiling of an ASP.NET Core web application using the dotMemory command line profiler on a Debian 64-bit VM. I am able to run the app (with process id 1234 for example) and then attach the memory profiler following instructions given on the JetBrains help page.

./dotMemory.sh attach 1234 --save-to-dir=~/Snapshots

I now want to start the app using the memory profiler to get more information. This is not working however.

  • I get the following error when I try to run the profiler as described on the help page.

    /PathToScript/dotMemory.sh start /PathToWebApp/bin/WebApp --save-to-dir=~/Snapshots

A fatal error occurred. The required library libhostfxr.so could not be found.

If this is a self-contained application, that library should exist in [/PathToWebApp/bin/].

If this is a framework-dependent application, install the runtime in the global location [/usr/share/dotnet] or use the DOTNET_ROOT environment variable to specify the runtime location or register the runtime location in [/etc/dotnet/install_location].

The .NET runtime can be found at:

  • I get a different error when I try to run the profiler with the ".dll" as part of the app name.

    /PathToScript/dotMemory.sh start /PathToWebApp/bin/WebApp.dll --save-to-dir=~/Snapshots

Unable to start profiling. An error occurred trying to start process '/PathToWebApp/bin/WebApp.dll' with working directory '/PathToWebApp'. Exec format error

  • I also tried using the dotnet keyword.

    /PathToScript/dotMemory.sh start dotnet /PathToWebApp/bin/WebApp.dll --save-to-dir=~/Snapshots

Value of argument is invalid. File doesn't exist: dotnet

Note that I am able to start the WebApp successfully using the same command.

 dotnet /PathToWebApp/bin/WebApp.dll

How can I launch the application using the dotMemory profiler?


Solution

  • Got the answer from JetBrains support: need to use the start-net-core command to start an application using the dll.

    /PathToScript/dotMemory.sh start-net-core /PathToWebApp/bin/WebApp.dll --save-to-dir=~/Snapshots