Why the “View Heap” result does not match with 'Process Memory Usage' in Visual Studio

前端 未结 2 1743
情深已故
情深已故 2020-12-29 02:06

I am trying to use Visual Studio to track memory usage in my app. In the \'Diagnostic Tools\' window, it shows my app is using 423 MB. Thank I go to \'Memory Usage\' and \'

2条回答
  •  死守一世寂寞
    2020-12-29 02:57

    The graph shows Private Bytes for the entire process. This includes the Managed heap, native heap, stacks, etc... See this answer for more on types of memory metrics: What is private bytes, virtual bytes, working set?

    The Heap View table only shows types active (not able to be garbage collected) on the Managed heap at the time the snapshot was taken. To see types on both the native and managed heaps, switch to mixed-mode debugging. The Heap View (and the number in snapshot table) are a subset of the process memory shown in the graph.

    The debugger-integrated tool works best for trying to find the cause of unexpected growth in memory, or tracking down objects that should have been garbage collected but have references still keeping them alive.

    Here's a blog post I wrote (I work for MSFT) on the Memory tool explaining how to track down objects with outdated references: https://web.archive.org/web/20150905153352/http://blogs.msdn.com/b/visualstudioalm/archive/2015/04/29/diagnosing-event-handler-leaks-with-the-memory-usage-tool-in-visual-studio-2015.aspx

提交回复
热议问题