This tutorial demonstrates launching a .Net Core application, closing the application and inspecting the memory leak results.
For this tutorial we’re going to work with dotNetCoreLauncher and consoleApp which are located in <Memory Validator install directory>\examples\dotNetCore\.
You will need to build these with Visual Studio 2019 (.Net Core 5) or Visual Studio 2022 (.Net Core 6). A solution file is provided for each version. If you’ve installed in the default program files location you’ll need to run Visual Studio in administrator mode to do the build.
We’re going to show you how to detect memory leaks for a child process launched from a .Net Core application. The process is the same for both Framework-dependent and Self-contained .Net Core applications. But the process is slightly different depending on whether the child process is Framework-dependent, Self-contained, .Net or native.
Publishing the .Net Core application allows you to create an application that is framework dependent, or which is self contained.
The following command will create a framework dependent version and a self contained x64 version using Visual Studio 2019 and Visual Studio 2022.
Open a command prompt with administrator privileges.
cd c:\Program Files (x86)\Software Verify\Memory Validator x64\examples\dotNetCore
publish.bat
You can also use publish_vs2019.bat and publish_vs2022.bat for use with specific versions of Visual Studio.
We’re going to start dotNetCoreLauncher that we just built with publish.bat. This is in <Memory Validator install dir>\examples\dotNetCore\dotNetCoreLauncher\dotNetCoreLauncher\bin\debug\net5.0\win-x64\. You may need to replace net5.0 with net6.0 on your machine.
Select the dotNetCoreLauncher_vs2019.dll using the Browse… button next to the Application to launch (*.dll) field.
When you do this the Application to launch (*.exe) and Application to Monitor fields are populated with the .Net Core runtime, and the Application to launch (*.dll) is populated with the choice of dll.
The process for self contained .Net Core is very similar to the process described above for Framework Dependent .Net Core.
The difference is just how you specify the application to launch.
How you specify the child processes to monitor is identical to the process for Framework Dependent .Net Core.
We’re going to start dotNetCoreLauncher that we just built with publish.bat. This is in <Memory Validator install dir>\examples\dotNetCore\dotNetCoreLauncher\dotNetCoreLauncher\bin\debug\net5.0\win-x64\. You may need to replace net5.0 with net6.0 on your machine.
Select the dotNetCoreLauncher_vs2019.exe using the Browse… button next to the Application to launch (*.exe) field.
When you do this the Application to launch (*.dll) and Application to Monitor fields are populated with the executable, and the Application to launch (*.dll) is populated with a .Net Core dll that has the same name as the executable.