I'm using STM32 based microcontroller, IAR embedded workbench and STlink v2 debugger. I just want to know how to check the memory utilized/used by the program/system in various memory segments like:

  1. Data segment(initialized and uninitialized)
  2. heap segment
  3. stack segment

any suggestions regarding this would be appreciated.

  • 2
    \$\begingroup\$ Check your linker commands line options, there should be one to produce a linker map, from which you can find the size of the BSS, DATA and CODE segmenst. The heap and stack are 'determined' at run-time (check the startup code), but the boundaries might be prepared by the linker. \$\endgroup\$ – Wouter van Ooijen Apr 6 '15 at 8:52
  • 1
    \$\begingroup\$ What Wouter said. Also "objdump" if you're using gcc etc. \$\endgroup\$ – Brian Drummond Apr 6 '15 at 10:56
  • \$\begingroup\$ @WoutervanOoijen Thanks. I generated map file and then saw the sizes of code, data and BSS segments. What else we can do from the map file? \$\endgroup\$ – Myanju Apr 6 '15 at 11:28
  • \$\begingroup\$ @BrianDrummond I'm using IAR embedded workbench in windows OS. Any ways thanks for the suggestion really i appreciate that. \$\endgroup\$ – Myanju Apr 6 '15 at 11:30
  • \$\begingroup\$ @Myanju now you'll have to check the startup code (or maybe the implementation of malloc) to see how the stack and heap are initialized. \$\endgroup\$ – Wouter van Ooijen Apr 6 '15 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.