While many blogs talk about capturing memory dump for .NET application on Windows platform, this blog introduces one way of collecting .NET Core dump on Linux Web App with dotnet-dump tool.
1. SSH to web app.
2. Install .NET Core SDK with following commands. Here we use Debian 10 distribution as an example. For installing .NET Core SDK on other Linux distributions, you may refer to document at https://docs.microsoft.com/en-gb/dotnet/core/install/linux.
apt-get install -y wget
wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb
apt-get install -y apt-transport-https
apt-get install -y dotnet-sdk-3.1
3. Install dotnet-dump tool.
dotnet tool install –global dotnet-dump –version 3.1.141901
4. Refresh SSH session window to enable dotnet-dump command.
5. Check dotnet process id. In example below, process id of the web app is 29.
ps aux | grep dotnet
6. Change directory to persistent storage.
7. Capture dotnet core dump.
dotnet-dump collect -p [process-id] –type Full –diag
Specifies the process ID number to collect a dump from.
Specifies the dump type, which determines the kinds of information that are collected from the process. There are three types:
Full – The largest dump containing all memory including the module images.
Heap – A large and relatively comprehensive dump containing module lists, thread lists, all stacks, exception information, handle information, and all memory except for mapped images.
Mini – A small dump containing module lists, thread lists, exception information, and all stacks.
Enables dump collection diagnostic logging.
8. Once capture completed, we should be able to see dump file in the “/home/LogFiles” directory.