I have been trying to figure out the overall memory usage of my C program, but for whatever reason Cosmic C doesn't seem to provide a summary. Did a bit of googling and found a program call MapInfo from a Chinese website.
The Chinese BBS is here (with download) : http://www.amobbs.com/forum.php?mod=viewthread&action=printable&tid=4069099
The English description is here (missing download): http://prog3.com/sbdm/blog/chuangwu2009/article/details/25879643
There is a bug fixed version somewhere down the comments. This one also comes with C source code.I used virustotal which uses 55 anti-virus scanners for testing the file. Someone might alter the files, so do the test yourself.
MapInfo for Cosmic ourdev_593473S9G527.ziphttp://cache.amobbs.com/bbs_upload782111/files_34/ourdev_593473S9G527.zip (File Size: 19K) (the original file name: mapinfo.zip)
MapInfo uses the .map file from the compiler. To enable the .map file, right click on the project and go to the Linker tab: Output and select the "Generate Map file" option.
I copy the executable into the compiler directory.
"C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8"
The next step is to add MapInfo command in the Post-Build tab by copy the following line into the command field.
MapInfo $(OutputPath) $(TargetSName).Map
Here is the output:
So what is it reporting for my program?
It seems to add up the ones circled in Red for the flash size and green for the eeprom. (Additional fields are used - see source code).
The updated version seem to pick up the stack usage:
It looks like the stack size is the largest of the first column 17 added to the largest of the second column (6). I am guessing first column is the call stack and second column is the local variable on the stack.
Stack size: 17+6 = 23.
If you rather not trust some Chinese BBS boards, you could write one yourself using this info. It is a matter of parsing the text in the map file. It is about 1st year computer science difficulty level.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.