Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic High memory usage with an Arduino Zero (Read 857 times)
shawn55
Newbies
*
Offline


Posts: 1
Joined: Nov 24th, 2023
High memory usage with an Arduino Zero
Nov 24th, 2023 at 4:29pm
Print Post  
A Release build in Microchip Studio 7 of an empty program/sketch, i.e. an empty setup/loop, is using almost 3K of memory on my Arduino Zero/SAMD21 (Minimum Memory Usage: 2980 bytes (9% of a 32768 byte maximum)). We are developing a memory restricted program where every byte counts and this seems like a lot of memory for an empty Release build. Is this expected and if so can it be reduced somehow? 
Also, to gather more information, I tried to enable the Monitor Free Memory feature in a Debug build with the Serial debugger enabled but I got the following build errors (Note: the serial debugger works fine without Monitor Free Memory enabled): 
VM_DBG.cpp.o: In function VisualMicroDebug::printFreeMemory()
VM_DBG.cpp:1650: undefined reference to _VM_freeMemory
 
collect2.exe*: error: ld returned 1 exit status
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2716
Joined: Feb 13th, 2019
Re: High memory usage with an Arduino Zero
Reply #1 - Nov 24th, 2023 at 5:09pm
Print Post  
Thanks for the report.

The memory usage on the empty Release sketch is unrelated to Visual Micro and is how the Arduino core software is built , which is identical in the Arduino IDE.

From the log the Optimization is already at its smallest for the code size as well (-Os).

One option to gain more memory would be to change to a more modern MCU which has more memory available to it (e.g. Teensy 4.1 has 1024K of RAM available with expansion for additional PSRAM also available), which also offers a vastly higher CPU speed as well (up to 1Ghz!).  I have assumed no WiFi or Bluetooth functionality is needed as with the Arduino Zero.

The only alternative to stick with the same chip would be to do away with all Arduino core functionality (and optionally the bootloader to save on code space) and program it directly in e.g. AS7 in C++, which would require more knowledge as none of the helpers provided by Arduino (e.g. digitalWrite(), Serial.println() etc) will be available and are often chip specific when working with registers etc...

We have identified the issue with the FreeMemory reporting not working, which we can send you the files to resolve, however this functionality itself will consume some code space and memory to work, which may not be desirable if your code is expected to be very close to these limits.  Let us know if you want us to send these over.

Finally, it is also worth pointing out that some microcontrollers preallocate memory. This means that adding "some" code does not increase the size of the memory usage. The serial buffer(s) can sometimes be a good example of that. Again, this is designed within whatever board package you have installed, in this case it is the Arduino.cc SAMD core.

« Last Edit: Nov 25th, 2023 at 5:10pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint