{"id":2585,"date":"2017-03-08T22:39:00","date_gmt":"2017-03-08T22:39:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/pix\/?page_id=2585"},"modified":"2017-03-08T22:39:00","modified_gmt":"2017-03-08T22:39:00","slug":"data-type-tracking-in-memory-allocation-captures","status":"publish","type":"page","link":"https:\/\/devblogs.microsoft.com\/pix\/data-type-tracking-in-memory-allocation-captures\/","title":{"rendered":"Data Type Tracking in Memory Allocation Captures"},"content":{"rendered":"<p>The PIX memory profiler will show data type information for heap allocations when it is available. Type information will be available if the following two conditions are met:<\/p>\n<ol>\n<li>The function that allocated the type has been decorated with __declspec(allocator)<\/li>\n<li>PIX can find your title\u2019s PDB.<\/li>\n<\/ol>\n<p>The memory allocation routines in the default heap are already decorated with __declspec(allocator) so unless you have custom memory allocation routines, there is no other work you\u2019ll need to do related to __declspec(allocator).\u00a0 If your heap allocations are coming from somewhere other than the default heap, see the <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/tracking-custom-memory-allocations-with-visual-studio-15-preview-2\/\">blog post on tracking custom allocations <\/a>for instructions on how to use __declspec(allocator).<\/p>\n<p>The &#8220;Setting PDB Paths&#8221; section of the <a href=\"https:\/\/blogs.msdn.microsoft.com\/pix\/function-summary-captures\/\">Function Summary Capture <\/a>page provides instructions for configuring PIX to find your title\u2019s PDBs.\u00a0 Briefly, if you\u2019re profiling on the same machine you just built your title on, the path to the PDB that the compiler stored in your title\u2019s modules is typically all PIX needs to locate the PDB.\u00a0 Otherwise, there are options on the Settings page to point PIX at your PDBs.<\/p>\n<p>Type information is shown in two places in a memory capture.\u00a0 First, the event list on the Events tab has a column called Type Name in which the name of the allocated type is displayed.\u00a0 PIX will only be able to display the type name if the allocation routine was decorated with __declspec(allocator) as described above.<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/03\/memory_type_info1.png\"><img decoding=\"async\" width=\"1482\" height=\"691\" class=\"alignnone size-full wp-image-2595\" alt=\"memory_type_info1\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/03\/memory_type_info1.png\" srcset=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2017\/03\/memory_type_info1.png 1482w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2017\/03\/memory_type_info1-300x140.png 300w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2017\/03\/memory_type_info1-768x358.png 768w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2017\/03\/memory_type_info1-1024x477.png 1024w\" sizes=\"(max-width: 1482px) 100vw, 1482px\" \/><\/a><\/p>\n<p>The second place that type information is displayed is on the Allocated Types tab.\u00a0 Statistics are provided for every type that was allocated while the capture was running.\u00a0 These statistics include the size of the type, the amount of padding in the type&#8217;s definition, the number of instances of the type that were allocated and the total number of bytes those allocations took up in the heap.<\/p>\n<p>Clicking on a column sorts the event list based on the data in the column.\u00a0 Sorting can quickly help you see things like which types were allocated most frequently, which types have the most padding and so on.<\/p>\n<p>Selecting a row in the event list populates the Type Info view with details of the type&#8217;s layout.\u00a0 The Type Info view will show you the offset and size of each field in the type.\u00a0 Nested types can be expanded and collapsed.\u00a0 The layout also tells you exactly where the padding sits within your type information.\u00a0 This padding information helps you determine whether your layout can be optimized to reduce wasted space.<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/03\/memory_type_info2.png\"><img decoding=\"async\" width=\"1364\" height=\"593\" class=\"alignnone size-full wp-image-2605\" alt=\"memory_type_info2\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/03\/memory_type_info2.png\" srcset=\"https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2017\/03\/memory_type_info2.png 1364w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2017\/03\/memory_type_info2-300x130.png 300w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2017\/03\/memory_type_info2-768x334.png 768w, https:\/\/devblogs.microsoft.com\/pix\/wp-content\/uploads\/sites\/41\/2017\/03\/memory_type_info2-1024x445.png 1024w\" sizes=\"(max-width: 1364px) 100vw, 1364px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The PIX memory profiler will show data type information for heap allocations when it is available. Type information will be available if the following two conditions are met: The function that allocated the type has been decorated with __declspec(allocator) PIX can find your title\u2019s PDB. The memory allocation routines in the default heap are already [&hellip;]<\/p>\n","protected":false},"author":1915,"featured_media":4769,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"footnotes":""},"class_list":["post-2585","page","type-page","status-publish","has-post-thumbnail","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/pages\/2585","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/users\/1915"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/comments?post=2585"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/pages\/2585\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/media\/4769"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/pix\/wp-json\/wp\/v2\/media?parent=2585"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}