Questions tagged [memory-usage]
Use this tag for questions about memory usage on the Arduino.
22 questions
9
votes
1
answer
1k
views
Overview of compiled code size
When I compile my code, the Arduino IDE returns the binary sketch size in byte.
Is there a good way to find out (approximately) what function or what part of my code takes up how much memory in ...
2
votes
1
answer
1k
views
Measure SRAM usage
I am using an Arduino with 2048 bytes of SRAM. I have a complex project so that it is no longer obvious how much SRAM it would use in total (there is not one large dominant object but many different ...
13
votes
1
answer
19k
views
Can I write to Flash Memory using PROGMEM?
On the documentation of Arduino, I quote:
http://playground.arduino.cc/Learning/Memory
Note: Flash (PROGMEM) memory can only be populated at program burn time. You can’t change > the values in the ...
12
votes
4
answers
9k
views
Why is it considered bad practice to use the 'new' keyword in Arduino?
I previously asked this question:
Is it required to delete variables before going to sleep?
On that question, @Delta_G posted this comment:
... Really on a microcontroller I would create the object ...
7
votes
4
answers
5k
views
Detailed analyse of memory usage
When compiling a sketch, after linking, the build outputs a kind of forecast on RAM usage, e.g.:
Minimum Memory Usage: 1456 bytes (71% of a 2048 byte maximum)
Is it possible to somehow get a ...
4
votes
1
answer
989
views
ATTiny13 Interrupt Issue
I have recently been working on a project that I had initially been designing with an Arduino Nano, and I was able to create functioning code for my application, but for cost / space reduction I ...
3
votes
2
answers
689
views
Memory allocation on Arduino Due never returns NULL
I'm working on a project that uses quite a bit of RAM to store and analyze data that is sent from the PC. The program heavily relies on malloc/free, which normally works just fine. However, if the ...
3
votes
2
answers
2k
views
What is the memory expense of creating a String from a char array?
I'm writing a little API for processing email messages in Arduinos. Obviously, I need to keep memory use down, but I also want to allow the end user to use the String functions (like indexOf) to ...
2
votes
1
answer
1k
views
What is using up all the RAM in my program?
I am running a program on the ATtiny and for some reason I am way over the 512 bytes of RAM that are available to me. This is confusing because when I did the math by hand I should have 432 bytes. ...
-1
votes
2
answers
268
views
How can I make this program take up less memory?
I'm measuring how long it takes to drain a battery. An Arduino Nano controls an SSD1036 OLED display, a board with two relays, and an INA3221 voltage/current measurement board.
The battery is ...
9
votes
3
answers
11k
views
PROGMEM: do I have to copy data from flash to RAM for reading?
I have got some difficulties understanding the memory management.
Arduino documentation says, it is possible to keep constants like strings or whatever I don't want to change during runtime in ...
8
votes
2
answers
4k
views
OOP vs Inline with Arduino
I have been programming for quite a while now but I am new to Arduino and AVR Programming. The main question I have about programming these Micro-controllers is are there major differences in ...
8
votes
4
answers
4k
views
What are the traditional ways to optimize program memory usage?
While doing big projects using Arduino boards (Uno, Atmega328P MCU). I used to get warnings like this
Sketch uses 13764 bytes (44%) of program storage space. Maximum is 30720 bytes.
Global variables ...
3
votes
3
answers
1k
views
Is this function subject to memory fragmentation?
I'm trying to understand if the following bit of code is subject to memory fragmentation.
Let's say I incrementally build a string within a function and I don't know how large the string should be.
...
2
votes
1
answer
731
views
What will use less memory, an array or if ... else?
I'm trying to make my sketch smaller. Right now I use an array for the AM/PM part of my time display. My thinking is this makes it easy to change the formatting:
char* ampms[]= {"am", "pm"};
void ...