Introduction: Arduino Memory Usage Report Is Displayed After Each Compile

About: News November 2019. Welcome to the place where we have started to build useful examples. Arduino for Visual Studio provides an Arduino compatible development environment in Microsoft Visual Studio. The tools p…

The Microsoft Visual Studio Professional development system, with the free Arduino Plugin, can be used to program any Arduino micro-controller. Visual Studio provides a 100% compatible Arduino build system.

Visual studio also provides additional features such as optionally reporting the memory usage of a compiled Arduino program.

Memory usage is especially important when creating projects for small micro-controllers such as the Arduino. The Arduino will crash without warning if a program exceeds the available limits. So this makes it quite important that we are able to know how much memory a program will use when it starts.

This is especially so for new users who naturally add many serial debug messages to their code. Each type of Arduino has different memory limits but all are very low, it doesn't take many debug messages to fill the memory. More experienced users creating larger programs will also be aware of the limits.

The following describes how to enable automatic memory usage reports during compilation of an Arduino program. The ArduPilot open source drone project is used in this example because it was easily available.

When enabled (see Step 1), the Arduino memory usage report is automatically displayed after each compile in the "Micro Build" output window. In the example report you see that the (data) memory used is 52.5%.

You can also see in the image the dynamic memory usage available using the optional Arduino Debug Tool for Visual Studi. More details of dynamic memory reporting can be found here

Step 1: Arduino Memory Usage Report Is Displayed After Each Compile

The memory usage report is enabled using the Visual Studio project properties window.

The project properties window is displayed by selecting the project node in the Visual Studio solution explorer and pressing F4 or "View>Properties Window" or "View>Other Windows>Properties Window"

Notes

The program size can be ignored because both the Arduino IDE and Visual Studio will prevent program upload if the program is too large for the hardware. However neither development systems monitor the "data" memory usage which makes this report very useful.

Reference

The free Arduino plugin for Microsoft Visual Studio can be found here
At the time of writing this article Visual Studio can be obtained legally for free for 3 years from here