What does “Private Data” define in VMMAP?

后端 未结 1 1807
执笔经年
执笔经年 2021-02-15 02:01

I am using VMMap to analyse Virtual/Process Address Space utilisation in my mixed mode (managed and unmanaged) application. I understand how the Windows VMM and the Virtual Memo

1条回答
  •  南方客
    南方客 (楼主)
    2021-02-15 02:57

    I know it's a pretty old question. But it's still unanswered for some reason. This question was mentioned by Sasha Goldstein in his talk about WinDbg at DotNext conference - https://www.youtube.com/watch?v=8t1aTbnZ2CE. The point was it can be easily answered with help of WinDbg.

    To answer whether CLR uses VirtualAlloc for its heap we'll set a breakpoint at this function with a script which prints current stack (native and managed).

    bp kernelbase!VirtualAlloc ".printf \"allocating %d bytes of virtual memory\", dwo(@esp+8);.echo;  k 5; !clrstack; gc"
    

    Here: k 5 print last 5 frames of native callstack and !clrstack (from SOS) prints managed stack. gc continue execution.

    Please note that this script will work only for x86 processes. For x64 you'll need some other (registries and calling convention differ).

    Then I created a simple program which allocate an object and adds it to a List.

        static void Main(string[] args)
        {
            var list = new List();
            while (true) {
                var a = Console.ReadLine();
                if (a == "q" || a == "Q") break;
                var arr = new string[100];
                list.Add(arr);
            }
        }
    

    Run it under WinDbg and started pressing Enter. At some point the breakpoint hit - on List expanding and allocating additional memory in the heap:

    So obviously CLR uses VirtualAlloc for allocating memory for its heap.

    0 讨论(0)
提交回复
热议问题