Reputation: 1
I have a C code which I compile for ARM, it's then running on an ARM device. I am interested in the memory usage of the program, i.e. the heap and stack allocations.
Is there any tool that would allow me to measure those values? So far what I get is only the linker output from armlink, but with those values I cannot calculate heap and stack. I am currently using the ARM Workbench IDE, but I couldn't find anything related to this problem.
Upvotes: 0
Views: 1087
Reputation: 1
Actually, you can gain some insight into stack usage with the GCC compiler option -fstack-usage and a perl script called avstack.pl, which generates a call graph. For information on the perl script, see https://dlbeer.co.nz/oss/avstack.html for both documentation and the script itself. You will need to modify the script as indicated in the documentation. It is not ideal, but it is the best open-source solution that I have seen thus far.
Upvotes: 0
Reputation: 400059
In general heap and stack usage both have to be measured, you can't statically analyze the code and figure them out.
Luckily in embedded code, it's often easier to just jump into the code for e.g. malloc()
and make it include measurements, which you can then inspect using a debugger for instance.
Stack usage can sometimes be more passively measured, by filling the stack space with some known data and checking for the "high water mark" left when the application overwrites the filler with actual data.
Both of these approaches will of course require exercising the program, i.e. making it run through the various code paths that use these resources (again, this is a dynamic measurement, not static analysis).
Upvotes: 1