Reputation: 21
In Visual Studio 2022, when I use the Memory Usage tool and set it to "Enable native heap profiling with snapshots", it only includes managed allocations, not native allocations.
In Visual Studio 2019, when I run the same tool on the same project, it does include native allocations.
The debug profile has "Enable native code debugging" turned on. (Though this doesn't seem necessary for VS 2019 to capture a native heap.)
What is it about my VS 2022 installation or settings that are preventing native snapshots? Or am I missing something in the VS 2022 UI?
The test code:
class Program
{
private static void Main(string[] args)
{
System.Console.WriteLine("Take first snapshot");
System.Console.ReadKey();
// Alloc 1 GB unmanaged memory
var handles = new System.IntPtr[100];
for (int i = 0; i < handles.Length; i++)
{
handles[i] = System.Runtime.InteropServices.Marshal.AllocHGlobal(10 * 1024 * 1024);
}
System.Console.WriteLine("Take second snapshot");
System.Console.ReadKey();
}
}
In VS 2019:
VS 2019 setting Memory Usage to Mixed
VS 2019 snapshot has Native Heap
In VS 2022:
VS 2022 setting Memory Usage to Enable Native heap profiling
VS 2022 snapshot has no Native Heap
Upvotes: 2
Views: 2189