{"id":6523,"date":"2015-01-29T01:02:00","date_gmt":"2015-01-29T01:02:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2015\/01\/29\/native-memory-diagnostics-in-ctp-5\/"},"modified":"2021-10-06T14:52:30","modified_gmt":"2021-10-06T14:52:30","slug":"native-memory-diagnostics-in-ctp-5","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/native-memory-diagnostics-in-ctp-5\/","title":{"rendered":"Native Memory Diagnostics in CTP 5"},"content":{"rendered":"<p>The Visual Studio <em>Memory Usage<\/em> tool is now selected by default in <a href=\"http:\/\/www.visualstudio.com\/en-us\/news\/vs2015-vs.aspx\">VS2015 CTP 5<\/a>.&nbsp; When you first debug a native app in CTP 5, the <em>Diagnostic Tools<\/em> window will launch and show both the <em>Memory Usage<\/em> and <em>CPU Usage<\/em> tools since they are both checked by default.&nbsp; For more information on the Diagnostic Tools window and other tools, please consult <a href=\"http:\/\/blogs.msdn.com\/b\/visualstudioalm\/archive\/2015\/01\/16\/diagnostic-tools-debugger-window-in-visual-studio-2015.aspx\">this blog post<\/a> by Dan Taylor.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2015\/01\/6355.1.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2015\/01\/6355.1.png\" alt=\"Image 6355 1\" width=\"493\" height=\"354\" class=\"aligncenter size-full wp-image-29382\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2015\/01\/6355.1.png 493w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2015\/01\/6355.1-300x215.png 300w\" sizes=\"(max-width: 493px) 100vw, 493px\" \/><\/a><\/p>\n<p>By clicking on <em>Select Tools<\/em>&nbsp;you can enable\/disable these tools.&nbsp; For the purposes of this blog post, I have already selected only the memory tool to simplify the screenshots.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2015\/01\/4428.2.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2015\/01\/4428.2.png\" alt=\"Image 4428 2\" width=\"339\" height=\"122\" class=\"aligncenter size-full wp-image-29380\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2015\/01\/4428.2.png 339w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2015\/01\/4428.2-300x108.png 300w\" sizes=\"(max-width: 339px) 100vw, 339px\" \/><\/a><\/p>\n<p>Notice that in the bottom pane there is an option to enable heap snapshots on the next debugging session:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2015\/01\/4571.3.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2015\/01\/4571.3.png\" alt=\"Image 4571 3\" width=\"426\" height=\"271\" class=\"aligncenter size-full wp-image-29381\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2015\/01\/4571.3.png 426w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2015\/01\/4571.3-300x191.png 300w\" sizes=\"(max-width: 426px) 100vw, 426px\" \/><\/a><\/p>\n<p>By default, the native snapshots are disabled to preserve runtime performance while debugging. &nbsp;The description in the center of the lower pane explains what this feature does and the inherent performance impact:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2015\/01\/3731.5.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2015\/01\/3731.5.png\" alt=\"Image 3731 5\" width=\"374\" height=\"67\" class=\"aligncenter size-full wp-image-29384\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2015\/01\/3731.5.png 374w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2015\/01\/3731.5-300x54.png 300w\" sizes=\"(max-width: 374px) 100vw, 374px\" \/><\/a><\/p>\n<p>Once the snapshots toggle has been set to <em>Yes<\/em>, restart the debugger and the snapshot reel will work on your subsequent debugging sessions:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2015\/01\/8836.4.gif\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2015\/01\/8836.4.gif\" alt=\"Image 8836 4\" width=\"853\" height=\"425\" class=\"aligncenter size-full wp-image-29383\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Native vs. Managed: Differences in Heap Analysis Overhead<\/strong><\/p>\n<p>Since the managed memory collector does not experience the processing overhead until the end of the collection, the runtime impact is negligible so heap snapshots are enabled by default.&nbsp; Due to the fact that both memory tools share a checkbox in the Diagnostic Tools window, we added the additional option for native apps to enable snapshots for future debug sessions to preserve F5 runtime performance.&nbsp; In the tool&rsquo;s native allocation tracing process, there is a constant penalty in terms of runtime performance.&nbsp; Depending on the number and usage of allocations, the runtime slowdown could range anywhere from around 20% to as high as about three times for an allocation intensive app(based on our initial tests).&nbsp; Such runtime overhead is unfortunately inevitable in a memory allocation tracking tool and comparable to other tools available today.<\/p>\n<p>In the future we plan to have a set of options for the <em>Memory Usage<\/em> tool where developers can enable native heap snapshots before starting a debugging session on an app, similar to what&nbsp;is available in the <a href=\"http:\/\/blogs.msdn.com\/b\/visualstudioalm\/archive\/2014\/04\/02\/diagnosing-memory-issues-with-the-new-memory-usage-tool-in-visual-studio.aspx\">earlier version<\/a> of the memory profiler:<\/p>\n<p><strong>Now with 64-bit support!<\/strong><\/p>\n<p>There were multiple requests for 64-bit profiling support on my <a href=\"http:\/\/blogs.msdn.com\/b\/vcblog\/archive\/2014\/11\/21\/native-memory-diagnostics-in-vs2015-preview.aspx\">last blog post<\/a>, so I am very pleased to announce that we now support profiling:<\/p>\n<ul>\n<li>64-bit native Win32 projects<\/li>\n<li>64-bit managed desktop projects<\/li>\n<\/ul>\n<p>Windows Store 64-bit profiling support is coming soon. Please try out the tool and let us know what you think!<\/p>\n<p>&nbsp;<\/p>\n<p>Thanks,<\/p>\n<p>Adam Welch<\/p>\n<p>Visual C++ Team<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Visual Studio Memory Usage tool is now selected by default in VS2015 CTP 5.&nbsp; When you first debug a native app in CTP 5, the Diagnostic Tools window will launch and show both the Memory Usage and CPU Usage tools since they are both checked by default.&nbsp; For more information on the Diagnostic Tools [&hellip;]<\/p>\n","protected":false},"author":295,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[140,100,55,194,236,104],"class_list":["post-6523","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus","tag-c","tag-c-language","tag-debugging","tag-diagnostics","tag-memory-leaks","tag-memory-management"],"acf":[],"blog_post_summary":"<p>The Visual Studio Memory Usage tool is now selected by default in VS2015 CTP 5.&nbsp; When you first debug a native app in CTP 5, the Diagnostic Tools window will launch and show both the Memory Usage and CPU Usage tools since they are both checked by default.&nbsp; For more information on the Diagnostic Tools [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/6523","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/295"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=6523"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/6523\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/35994"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=6523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=6523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=6523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}