Demystify Windbd memory usage labels: “Private Wor

2019-08-03 16:05发布

问题:

After a run, i see that my application takes 3.5Gb in TaskMgr

What I see in Windbg is a little bit confusing:

0:022> !address -summary
 ProcessParametrs 0000000001b7ed70 in range 0000000001b7e000 0000000001b80000
 Environment 0000000001c0c970 in range 0000000001c0c000 0000000001c0e000

-------------------- Usage SUMMARY --------------------------
    TotSize (      KB)   Pct(Tots) Pct(Busy)   Usage
   1037fe000 ( 4251640) : 00.05%    87.22%    : RegionUsageIsVAD
   7fed67a5000 (8585059988) : 99.94%    00.00%    : RegionUsageFree
    7dd6000 (  128856) : 00.00%    02.64%    : RegionUsageImage
    1900000 (   25600) : 00.00%    00.53%    : RegionUsageStack
      32000 (     200) : 00.00%    00.00%    : RegionUsageTeb
     950000 (    9536) : 00.00%    00.20%    : RegionUsageHeap
   1bff4000 (  458704) : 00.01%    09.41%    : RegionUsagePageHeap
       1000 (       4) : 00.00%    00.00%    : RegionUsagePeb
          0 (       0) : 00.00%    00.00%    : RegionUsageProcessParametrs
          0 (       0) : 00.00%    00.00%    : RegionUsageEnvironmentBlock
       Tot: 7ffffff0000 (8589934528 KB) Busy: 000000012984b000 (4874540 KB)

-------------------- Type SUMMARY --------------------------
    TotSize (      KB)   Pct(Tots)  Usage
   7fed67b5000 (8585060052) : 99.94%   : <free>
    7dd7000 (  128860) : 00.00%   : MEM_IMAGE
    2e76000 (   47576) : 00.00%   : MEM_MAPPED
   11ebee000 ( 4698040) : 00.05%   : MEM_PRIVATE

-------------------- State SUMMARY --------------------------
    TotSize (      KB)   Pct(Tots)  Usage
   df283000 ( 3656204) : 00.04%   : MEM_COMMIT
   7fed67b5000 (8585060052) : 99.94%   : MEM_FREE
   4a5b8000 ( 1218272) : 00.01%   : MEM_RESERVE

So, 99.94% of memory is RegionUsageFree ?

Can someone demystify the terms above ? RegionUsageFree means memory was free'd and can be used ? What is Private Working Set means ?

If free, why is shown in Private Working Set ? Should I worry about this ? That memory can be (re)used ? I'm on 64 bit, OOM is not an issue here, on 32 it might be ? How can I reduce this Private Working Set ?

PS: The heap look good:

0:022> !heap -s
LFH Key                   : 0x0000005b29625009
Termination on corruption : ENABLED
          Heap     Flags   Reserv  Commit  Virt   Free  List   UCR  Virt  Lock  Fast 
                            (k)     (k)    (k)     (k) length      blocks cont. heap 
-------------------------------------------------------------------------------------
00000000000e0000 00000002    1024      8   1024      3     1     1    0      0      
0000000003c20000 00001002     512      8    512      3     1     1    0      0      
0000000004d40000 00001002     512      8    512      3     1     1    0      0      
00000000001e0000 00008000      64      8     64      5     1     1    0      0      
00000000070e0000 00001002      64      8     64      3     1     1    0      0      
0000000004d30000 00001002      64      8     64      3     1     1    0      0      
0000000007010000 00001002     512      8    512      3     1     1    0      0      
0000000004d00000 00001002      64      8     64      3     1     1    0      0      
000000000c8b0000 00001002     512      8    512      3     1     1    0      0      
00000000070b0000 00001002      64      8     64      3     1     1    0      0      
000000000ef00000 00001002      64     32     64     27     1     1    0      0      
0000000012180000 00001002     512      8    512      3     1     1    0      0      
000000000f630000 00001002     512      8    512      3     1     1    0      0      
0000000010490000 00001002      64      8     64      3     1     1    0      0      
00000000105b0000 00001002     512      8    512      3     1     1    0      0      
0000000012170000 00001002      64      8     64      3     1     1    0      0      
0000000039860000 00001002     512      8    512      3     1     1    0      0      
00000000397e0000 00001003     512      8    512      5     1     1    0    bad      
000000003ca30000 00001003     512      8    512      5     1     1    0    bad      
000000003dbc0000 00001003     512      8    512      5     1     1    0    bad      
0000000010900000 00001003     512      8    512      5     1     1    0    bad      
0000000012090000 00001003     512      8    512      5     1     1    0    bad      
0000000039730000 00001003     512      8    512      5     1     1    0    bad      
0000000010aa0000 00001003     512      8    512      5     1     1    0    bad      
00000000136b0000 00001002      64      8     64      3     1     1    0      0      
000000000eff0000 00001002      64      8     64      3     1     1    0      0      
0000000013590000 00001002      64      8     64      3     1     1    0      0      
0000000013850000 00001002      64      8     64      3     1     1    0      0      
000000000fd70000 00001002      64      8     64      3     1     1    0      0      
-------------------------------------------------------------------------------------

回答1:

TaskMgr and WinDbg both display right data. Look more about Private Working Set at How to interpret Windows Task Manager? 99.94% of memory is RegionUsageFree because x64 has 8TB size virtual address space in user mode and almost all of it is free and can be used. You do not must reduce working set. Windows trims working sets for you. (Although you can use VMMap Empty Working Set feature in the View menu) For more information see M. Russinovich blog Pushing the Limits of Windows: Virtual Memory.