{"id":4288,"date":"2018-11-28T14:25:08","date_gmt":"2018-11-28T22:25:08","guid":{"rendered":"https:\/\/visualgdb.com\/w\/?p=4288"},"modified":"2018-11-28T14:25:08","modified_gmt":"2018-11-28T22:25:08","slug":"comparing-memory-footprints-of-different-project-versions","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/arm\/comparebuilds\/","title":{"rendered":"Comparing Memory Footprints of Different Project Versions"},"content":{"rendered":"<p>This tutorial shows how to use\u00a0Memory Explorer to do a detailed comparison\u00a0of the memory footprint between several\u00a0builds of your project. We will create a basic project\u00a0for an STM32\u00a0microcontroller, will try different combinations of newlib and the advanced profiler\/semihosting framework and will show how to quickly analyze the memory\u00a0footprint differences between those combinations.<\/p>\n<p>Before you begin,\u00a0install VisualGDB 5.4 or later.<\/p>\n<ol>\n<li>Start Visual Studio and open the VisualGDB Embedded Project Wizard:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/01-newprj2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4309\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/01-newprj2.png\" alt=\"01-newprj\" width=\"896\" height=\"611\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/01-newprj2.png 896w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/01-newprj2-300x205.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/01-newprj2-130x90.png 130w\" sizes=\"(max-width: 896px) 100vw, 896px\" \/><\/a><\/li>\n<li>Proceed with the default\u00a0settings on the first page:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/02-msb.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4308\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/02-msb.png\" alt=\"02-msb\" width=\"886\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/02-msb.png 886w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/02-msb-300x235.png 300w\" sizes=\"(max-width: 886px) 100vw, 886px\" \/><\/a><\/li>\n<li>On the second page of the wizard select the ARM\u00a0toolchain and your device. Also switch the C library type to <strong>Default<\/strong>:<br \/>\n<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/03-device.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4307\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/03-device.png\" alt=\"03-device\" width=\"886\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/03-device.png 886w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/03-device-300x235.png 300w\" sizes=\"(max-width: 886px) 100vw, 886px\" \/><\/a><\/li>\n<li>Pick the &#8220;LEDBlink (HAL)&#8221; sample and click &#8220;Next&#8221;:<br \/>\n<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/04-sample1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4306\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/04-sample1.png\" alt=\"04-sample\" width=\"886\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/04-sample1.png 886w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/04-sample1-300x235.png 300w\" sizes=\"(max-width: 886px) 100vw, 886px\" \/><\/a><\/li>\n<li>In this tutorial we will not be debugging any code, so you can simply select &#8220;Built-in GDB Simulator&#8221; as the debug method and click &#8220;Finish&#8221; to create the project:<br \/>\n<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/05-nodebug.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4305\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/05-nodebug.png\" alt=\"05-nodebug\" width=\"886\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/05-nodebug.png 886w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/05-nodebug-300x235.png 300w\" sizes=\"(max-width: 886px) 100vw, 886px\" \/><\/a><\/li>\n<li>Once the project is created, add a printf() call to main() as shown below and build the project:<br \/>\n<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/06-build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4304\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/06-build.png\" alt=\"06-build\" width=\"1138\" height=\"773\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/06-build.png 1138w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/06-build-300x204.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/06-build-1024x696.png 1024w\" sizes=\"(max-width: 1138px) 100vw, 1138px\" \/><\/a><\/li>\n<li>The build output will display the overall memory utilization, but won&#8217;t provide any details about it. To begin looking into details, select View-&gt;Embedded Memory Explorer:<br \/>\n<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/07-eme1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4303\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/07-eme1.png\" alt=\"07-eme\" width=\"1138\" height=\"773\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/07-eme1.png 1138w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/07-eme1-300x204.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/07-eme1-1024x696.png 1024w\" sizes=\"(max-width: 1138px) 100vw, 1138px\" \/><\/a><\/li>\n<li>VisualGDB will display\u00a0an overview of various memories in your project:<br \/>\n<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/08-use.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4302\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/08-use.png\" alt=\"08-use\" width=\"1138\" height=\"773\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/08-use.png 1138w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/08-use-300x204.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/08-use-1024x696.png 1024w\" sizes=\"(max-width: 1138px) 100vw, 1138px\" \/><\/a><\/li>\n<li>Click &#8220;Display section layout&#8221; to view the physical placement of each section inside the\u00a0corresponding memories:<br \/>\n<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/09-textdata.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4301\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/09-textdata.png\" alt=\"09-textdata\" width=\"1138\" height=\"773\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/09-textdata.png 1138w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/09-textdata-300x204.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/09-textdata-1024x696.png 1024w\" sizes=\"(max-width: 1138px) 100vw, 1138px\" \/><\/a><\/li>\n<li>Now switch to the detailed view and expand the\u00a0<strong>.text<\/strong> section in the <strong>FLASH<\/strong> memory. You will see that one major contributor to the\u00a0FLASH memory use is the _vfprintf_r() function:<br \/>\n<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/10-vprintf.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4300\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/10-vprintf.png\" alt=\"10-vprintf\" width=\"1138\" height=\"773\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/10-vprintf.png 1138w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/10-vprintf-300x204.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/10-vprintf-1024x696.png 1024w\" sizes=\"(max-width: 1138px) 100vw, 1138px\" \/><\/a><\/li>\n<li>Open VisualGDB Project Properties and switch the C Library Type to\u00a0<strong>Newlib-nano with FP support<\/strong>:<br \/>\n<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/11-nano.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4299\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/11-nano.png\" alt=\"11-nano\" width=\"911\" height=\"701\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/11-nano.png 911w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/11-nano-300x231.png 300w\" sizes=\"(max-width: 911px) 100vw, 911px\" \/><\/a><\/li>\n<li>Build the project.\u00a0The Memory Explorer will show\u00a0the amount of memory that was freed up after switching\u00a0to the lightweight newlib-nano library:<br \/>\n<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/12-change.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4298\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/12-change.png\" alt=\"12-change\" width=\"1138\" height=\"773\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/12-change.png 1138w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/12-change-300x204.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/12-change-1024x696.png 1024w\" sizes=\"(max-width: 1138px) 100vw, 1138px\" \/><\/a><\/li>\n<li>Switch back to the detailed view. The memory explorer will show the size difference for each\u00a0symbol\u00a0in the ELF file (including the new and removed symbols):<br \/>\n<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/13-funcs.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4297\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/13-funcs.png\" alt=\"13-funcs\" width=\"1138\" height=\"773\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/13-funcs.png 1138w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/13-funcs-300x204.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/13-funcs-1024x696.png 1024w\" sizes=\"(max-width: 1138px) 100vw, 1138px\" \/><\/a><\/li>\n<li>You can use the sorting and filtering buttons to\u00a0sort the symbols by either the absolute size, or the size difference,\u00a0or to hide the symbols that were not changed compared to the previous build of your project:<br \/>\n<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/14-sort.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4296\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/14-sort.png\" alt=\"14-sort\" width=\"1138\" height=\"773\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/14-sort.png 1138w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/14-sort-300x204.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/14-sort-1024x696.png 1024w\" sizes=\"(max-width: 1138px) 100vw, 1138px\" \/><\/a><\/li>\n<li>Change the library type to\u00a0just newlib-nano (without FP support) and\u00a0build the project again.\u00a0The Memory Explorer will show how several FP-related symbols were removed from the project, while most of the other symbols remained unchanged:<br \/>\n<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/15-nofloat.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4295\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/15-nofloat.png\" alt=\"15-nofloat\" width=\"1138\" height=\"773\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/15-nofloat.png 1138w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/15-nofloat-300x204.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/15-nofloat-1024x696.png 1024w\" sizes=\"(max-width: 1138px) 100vw, 1138px\" \/><\/a><\/li>\n<li>Normally, the\u00a0Embedded Memory Explorer will compare the current build of your program to the previous one.\u00a0Alternatively, you can create checkpoints by saving any build of your choice under a different name and using it as a reference point later. Click &#8220;Save the current version for future comparison&#8221; and save it under the &#8220;MinimalNewlib&#8221; name:<br \/>\n<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/16-save.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4294\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/16-save.png\" alt=\"16-save\" width=\"1138\" height=\"773\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/16-save.png 1138w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/16-save-300x204.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/16-save-1024x696.png 1024w\" sizes=\"(max-width: 1138px) 100vw, 1138px\" \/><\/a><\/li>\n<li>Reference the Fast Semihosting and Profiler framework and build the project. Then set the &#8220;Exclude Sampling Profiler Code&#8221;\u00a0checkbox and build it again. The Embedded Memory Explorer will show the effects of removing the sampling profiler from the project:<br \/>\n<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/17-removesampling.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4293\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/17-removesampling.png\" alt=\"17-removesampling\" width=\"1138\" height=\"773\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/17-removesampling.png 1138w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/17-removesampling-300x204.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/17-removesampling-1024x696.png 1024w\" sizes=\"(max-width: 1138px) 100vw, 1138px\" \/><\/a><\/li>\n<li>In order to see the effects of adding the framework without the sampling profiler (i.e. compare the current build to the one\u00a0with no profiler framework at all),\u00a0switch the\u00a0reference build from the previous build to <strong>MinimalNewlib<\/strong>:<br \/>\n<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/18-switch.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4292\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/18-switch.png\" alt=\"18-switch\" width=\"1138\" height=\"773\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/18-switch.png 1138w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/18-switch-300x204.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/18-switch-1024x696.png 1024w\" sizes=\"(max-width: 1138px) 100vw, 1138px\" \/><\/a><\/li>\n<li>The Memory Explorer will now show how much FLASH and RAM is used by the current configuration of the semihosting\/profiler framework:<br \/>\n<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/19-min-newlib.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4291\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/19-min-newlib.png\" alt=\"19-min-newlib\" width=\"1138\" height=\"773\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/19-min-newlib.png 1138w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/19-min-newlib-300x204.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/19-min-newlib-1024x696.png 1024w\" sizes=\"(max-width: 1138px) 100vw, 1138px\" \/><\/a><\/li>\n<li>You can also\u00a0explore the disassembly of specific functions without starting a debug session. Simply right-click on any function in Memory Explorer and select &#8220;Disassemble selected function&#8221;:<br \/>\n<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/20-disasm.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4290\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/20-disasm.png\" alt=\"20-disasm\" width=\"1138\" height=\"773\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/20-disasm.png 1138w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/20-disasm-300x204.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/20-disasm-1024x696.png 1024w\" sizes=\"(max-width: 1138px) 100vw, 1138px\" \/><\/a><\/li>\n<li>This will switch the Memory Explorer into the Disassembly view, showing the exact\u00a0contents of the selected symbol. For your convenience, the instructions are grouped according to the corresponding source\u00a0lines and selecting a group in the disassembly view will highlight that line in the source view, as long as you are using Clang IntelliSense:<br \/>\n<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/21-annotated.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4289\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/21-annotated.png\" alt=\"21-annotated\" width=\"1138\" height=\"773\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/21-annotated.png 1138w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/21-annotated-300x204.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/10\/21-annotated-1024x696.png 1024w\" sizes=\"(max-width: 1138px) 100vw, 1138px\" \/><\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to use\u00a0Memory Explorer to do a detailed comparison\u00a0of the memory footprint between several\u00a0builds of your project.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[53,174],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/4288"}],"collection":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/comments?post=4288"}],"version-history":[{"count":1,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/4288\/revisions"}],"predecessor-version":[{"id":4310,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/4288\/revisions\/4310"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=4288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=4288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=4288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}