How can unmanaged memory usage be viewed?
How can unmanaged memory usage be viewed and monitored within Visual Studio in ac# project? Is there a way to check if allocated memory has been properly deleted later while debugging?
Code: pv_Memory = Marshal.AllocHGlobal(0x200000);
I am attempting to use the 'Diagnostics Tools' within Visual Studio 2015 and can see memory increasing, though it does not appear to separate out unmanaged objects and memory.
Any tips? Thanks.
Configuration: 1. Visual Studio 2015 2. C# application referencing a 3rd party .NET library, which is a wrapper for an unmanaged library 3. Windows 7
When you are using AllocHGlobal you are allocating from the unmanaged C/C++ Heap. You can track this with Heap allocation tracing.
class Program
{
private static IntPtr pv_Memory;
static void Main(string[] args)
{
Console.ReadLine();
for(int i=0;i<10;i++)
{
pv_Memory = Marshal.AllocHGlobal(0x200000);
}
Console.WriteLine("Hello World!");
Console.ReadLine();
}
}
xperf from the Windows Performance Toolkit allows you to attach to an already running process to get heap allocation data.
You can view the data with WPA. A good article is here: http://blogs.microsoft.co.il/sasha/2014/12/02/diagnosing-native-memory-leaks-etw-wpa/
This is quite powerful but it needs some practice.
Use MS inbuilt tool CLRProfiler and Perfmon(Performance monitor). you can get its documentation on internet see this link . check ILDASM(IL Disassembler) tool too.
链接地址: http://www.djcxy.com/p/57048.html上一篇: bash:哪个vs命令
下一篇: 如何查看非托管内存使用情况?