Arduino - Memory Usage and Disassembly Reporting

by Visual Micro 24. August 2012 14:29

The August 2012 release of the Arduino plugin for Visual Studio provides useful options to display memory usage and program disassembly reports as part of the Arduino compile process. The disassembly view might not be useful for arduino beginners but the memory usage report might be espcially useful for beginners.

Arduino processors have a relatively small amount of "running" data memory which is often quickly consumed by new users adding their own debug messages to arduino programs. Arduino debug messages are often serial messages such as:- Serial.println("Hello World, I am here at this place in my code!")

Long serial text messages like the one above will quickly fill up the arduino memory which might only be 2048 bytes (characters). Serial messages are just one example of memory consumption. If the Arduino attempts to overflow the available memory it will crash (freeze). A crash is both difficult to debug and also can be quite disasterous so best avoided!

It is true that the arduino has other small memory areas where data could be stored. The other memory areas are for another article and do not remove the need to monitor memory usage.

Arduino Memory Usage Report

The memory uage report is enabled using the visual studio project properties window as shown below. The properties window is displayed by selecting the project node in the viual studio solution explorer and pressing F4 (or "View>Properties Window")

How to enable Arduino memory and disassembly reporting

The arduino memory usage report is automatically displayed after each compile in the "Micro Build" output window shown below. The report shows memory usage after compilation.

NB: The memory usage report does not show the dynamic memory that might be allocated by an arduino program after it has started running on an arduino chip. Dynamic memory can be reported in visual studio using the visual micro debug upgrade or by adding code to your arduino program. See this reference for more info.

Arduino Program Disassembly Report

The disassembly view takes arduino learning to the next level or provides useful information for experienced arduino programers. The disassembly view is automatically displayed in the "Micro Disassembly" output window after each compile (see top picture of how to enable disassembly reports). Below you can see an exampe of the disassembly of the diydrones ArduPilot program

References

Microsoft Visual Studio Profressional is available for 3 years free (if you are an individual and not a professional web designer or working for a web design company)

The Visual Micro plugin for Visual Studio can be downloaded for free from www.visualmicro.com