Questions tagged [memory-usage]
Use this tag for questions about memory usage on the Arduino.
142
questions
-1
votes
0
answers
45
views
Camera object detection on arduino UNO?
I have wired an OV7670 camera module (without FIFO chip) to an arduino UNO with this code and wiring. I can see the images in the provided java app on my pc, it works as expected. How could I get ...
1
vote
1
answer
67
views
Conditional assignment of array
I have some really long global variable arrays filled with data.
There is a single function that processes the data. The function works on only one array everytime. This arrays value changes every ...
1
vote
1
answer
115
views
Why does Serial.print(1) cost 228 bytes more program memory compared to Serial.print((char)(48+1))?
Just discovered this. When I cast an int to a char inside a Serial.print statement it costs way less program memory. I'm not sure why. Could someone explain this to me?
In the following example the ...
2
votes
1
answer
111
views
How to make the compiler ensure that local variables memory allocation won't cause any RAM overflow during execution?
Upon compiling a sketch using the Arduino IDE, a message like the following gets displayed in the console:
Global variables use 1540 bytes (75%) of dynamic memory, leaving 508 bytes for local ...
-3
votes
1
answer
59
views
Which Arduino board would be sufficient for the following simulink project?
I'm trying to run a Fuzzy Logic MPPT Algorithm in Arduino UNO, here's the Simulink File
However when I try to upload the code, I get the following error
Is this project possible with UNO, if yes, ...
1
vote
2
answers
206
views
Is there a good reference for Arduino Due memory architecture and usage?
It's been harder than I expected to find a reference source or usage guide.
There's a number of sources I've looked at along the road to this question:
The Due is listed here and here as having 512KB ...
1
vote
0
answers
167
views
Save data permanently on ESP32
I'm working on a stage (this is my first bigger Arduino project), and I want to create an initializer for it, and for this, I want to store some variables in the memory of ESP32 WROVER-B. For this, I ...
1
vote
1
answer
158
views
1 global variable consuming 19% of memory
I am working on a simple project on talking to the serial monitor, and my only global variable ("int" type, named "incomingByte") is consuming a lot of memory. There is no problem ...
3
votes
2
answers
299
views
5V alternative to Due?
I've designed a circuit controlled by an Arduino Mega 2560 involving a number of external components all running on and sending out 5V signals. I'm now realizing that the 8Kb of SRAM on the Mega 2560 ...
2
votes
2
answers
285
views
How can i reduce my global variable use? Attiny85
I'm trying to compile my code but i keep exceeding my global variable memory by 12%.
Is there anything i can do in my code to further reduce RAM usage?
Or do i have to do modifications to the ...
1
vote
1
answer
433
views
Read bytes from PROGMEM array
Disclaimer: I just started using C++ and I'm a bit of a beginner. Keep that in mind as your answering.
So I recently bought my first Arduino. It's a customized one and it has an 8x8 display attached ...
0
votes
1
answer
59
views
Global array doesn't get assigned the space it would take up in memory
I have this sketch:
const uint32_t len = 65536;
uint8_t arr[len];
void setup() {}
void loop() {}
The length of the array should fit into the dynamic memory. However, when I compile the sketch it ...
3
votes
3
answers
872
views
Request for help condensing code and saving memory
I'm building a final project for a class that involves playing an audio file of a wave shield every time I scan an amiibo with an RFID scanner. I'm a pretty new programmer, so I'm not very familiar ...
1
vote
0
answers
158
views
Can data be stored in program storage space instead of dynamic memory?
I'm declaring an array at top level like so:
constexpr byte a[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; // whatever data
I'm referencing the array in such a way that it's not optimized away. When ...
1
vote
1
answer
132
views
How do I get the size of my program at runtime?
(This question is specific for the Arduino Due, but maybe there's a general answer to the question)
I'm using DueFlashStorage to store application data in the flash memory of my Arduino Due. That ...
2
votes
3
answers
106
views
Arduino Uno with Sensor, Bluetooth Module and tftlcd
In code attached below I am using tftlcd display of 2.4 inch in which i want to show clock as home page, when user click on tftlcd screen then a screen appears which can show three options to user ...
2
votes
4
answers
183
views
What would be the best way of dynamically 'change' instances regarding dynamic memory?
Since I'm very used to object oriented programming, I would like to use this into my design.
My application will have 4 led strips and each led strip will have a 'pattern' running on it. For this I ...
1
vote
0
answers
4k
views
how to clear heap memory in esp32?
I am using Free RTOS on esp32 in my program.
However at some point of time when I execute xTaskCreate() it returns -1 , which error is could_not_allocate_required_memory. In my program, each time i ...
3
votes
2
answers
420
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 ...
2
votes
2
answers
74
views
RAM cost of entering functions
A friend has told me I shouldn't rely on functions because, during execution, they occupy a significant amount of RAM.
Is that true or, if it isn't, what's the maximum suggested level of function ...
4
votes
1
answer
677
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 ...
5
votes
1
answer
417
views
Does the compiled binary of a sketch include uncalled functions from a library?
I am writing a GUI using a TFT display and the Adafruit GFX library and its default font on Arduino Nano.
I want to be memory efficient and I assumed that the 'optimise for size' default setting of ...
1
vote
2
answers
50
views
What happens, memory-wise, when I call a function from another function?
I'm inspecting where the memory is used in an application which runs on Arduino. To my surprise, there are several locations where 100 to 200 bytes are consumed by simply calling a function. Example:
...
2
votes
1
answer
203
views
Connect SDRAM to STM32
Well, first of all hello to everything and thanks for reading my question. I am designing a board with STM32F730R8T6 MCU, and I want to connect MT48LC16M16A2P-6A to it which is 4MB SDRAM chip. The ...
1
vote
0
answers
208
views
ESP8266 NodeMCU running out of heap
I'm trying to create SMS alarm using Twilio, Firebase and Arduino IDE. Using sensors I am measuring the temperature. If the temperature is higher than a specified value (ESP reads that value from ...
1
vote
0
answers
51
views
Having a bunch of global variables or calculate them on the go on an Arduino, as far as memory is concerned
So I'm new in the arduino world but I have a grasp of object oriented programming, and decided to write a little library for running games on an arduino mega using a display. My question is, I'm ...
0
votes
1
answer
283
views
Erasing 1 byte of external Flash memory (winbond)
i'm trying to use an external flash memory Winbond 25q64jvsiq for my Arduino Nano based project for audio recording purposes, to have extra memory for recording 1 byte audio samples, since Arduino ...
1
vote
0
answers
50
views
Port manipulation: Coding for two chips
I am using Arduino Nano to test a code that will be ported on an ATTiny chip, which will need to perform operations at a frequency near clock maximum, calling for a very succinct coding.
My goal: to ...
1
vote
0
answers
323
views
Understanding heap fragmentation
I finally understand why people do not allocate memory when it comes to micro-controllers. The reason is because as you allocate different objects on the heap of various sizes and then you delete them ...
12
votes
4
answers
7k
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 ...
1
vote
1
answer
372
views
Is it required to delete variables before going to sleep?
This tutorial shows how to put the arduino to sleep and use a watchdog to wake up at intervals:
https://youtu.be/urLSDi7SD8M
I been studding c++ and as I am getting better I am instantiating objects ...
0
votes
1
answer
79
views
If the code used for Arduino can be embedded into a permanent , callable memory, is there a way to create an OS for Arduino that runs on call?
This thought came into my mind on thinking about smartwatches.
Although those I saw on YouTube are really good, they don't seem to provide a real experience of a real smartwatch - one that has an OS ...
-3
votes
1
answer
1k
views
Any limitation on array size in Arduino Mega 2560?
I am writing an Arduino code with 3 arrays.
Two of those are double and other one is int. Further first two arrays have nearly 420 elements for each.
Now I noticed that with more that 89 elements on ...
1
vote
1
answer
200
views
What else is consuming Data Segment reported by avr-size?
I am facing a low memory available problem in arduino. I am compiling a big sketch for arduino mega 2560.
Analysing a .elf file, the avr-size tool gives:
text data bss dec hex filename
...
7
votes
4
answers
3k
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 ...
0
votes
1
answer
124
views
Efficient way to store array with repeating values?
So I have about 2000+ X and Y values where I will look up the Y value for a given X value. If I store the values naively they won’t fit in memory, however there are a lot of repeating values and the X ...
1
vote
2
answers
2k
views
Serial printing from Flash Memory (F() macro, PROGMEM, sprintf_P, SPTR)
I have been testing on an Arduino UNO various techniques for serial printing from Flash Memory instead of RAM. At the same time, I have been using the freeMemory() function from Adafruit.
I created a ...
0
votes
2
answers
426
views
Does toCharArray prevent a String being created on the heap?
I know it's bad to use Strings due to the memory problems that can occur.
I've tried to remove all instances of strings from my code.
But I'm not sure about this line:
http.getString().toCharArray(...
5
votes
4
answers
1k
views
How can a function/method determine if a const array passed in is PROGMEM (flash) or not (RAM)?
Is it possible for a function/method to know if a constant array that has been passed in is in flash or RAM?
If I have a method or function that receives a constant array that is in RAM, the array is ...
1
vote
1
answer
602
views
Serial.println using too much memory (not Strings)
I want to feed thousands of analog vibration sensor readings into an array as fast as possible, and then analyze them. Here is my sketch:
const int pSensor1 = A0;
const int aSize=10000;
int a[aSize];...
1
vote
2
answers
91
views
Gratuitious instantiation of `Serial`, why?
Let's take a very simple sketch, any simple one-.ino sketch. Say, just a led blinker like this
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
}
void loop()
{
...
0
votes
1
answer
63
views
I think i worn out all of my Arduino Uno memory
Hi my Arduino Uno stacked with a motor driver shield was working perfectly however I am using the same board for a while now and suddenly my board stopped working.
When I upload a code no matter what ...
1
vote
1
answer
384
views
Reduce Sketch Size Help!
I dont know what to do?
Sketch uses 3712 bytes (12%) of program storage space. Maximum is 30720 bytes.
Global variables use 210 bytes (10%) of dynamic memory, leaving 1838 bytes for local variables. ...
0
votes
1
answer
118
views
Porting "far" flash memory access from Arduino Mega to Due
I have a project that runs on the Arduino Mega 2560 which takes up almost the complete amount of flash memory available (https://github.com/fredlcore/bsb_lan/blob/master/BSB_lan.ino). Because of this, ...
2
votes
0
answers
440
views
why is memcpy of unsigned long killing my sampling speed?
I'm using a Mega 2560 to communicate with a mixture of analog (i.e. measured via analogRead()) and I2C based sensors. Sampled data is placed in a 16 byte array, then written to an SD card once a 512 ...
3
votes
2
answers
978
views
Is there a way to add external RAM (let's say 100 MB or 200 MB) in this audio buffer mixing context?
I'm coding a music sampler device: for fast playback / minimal latency (only a few milliseconds), it's better to have all audio .wav samples we want to use in RAM, so that when some of them are ...
0
votes
1
answer
93
views
Why the global variables info is not shown for Arduino Due in IDE?
If I compile a sketch for the Arduino Mega:
Sketch uses 1804 bytes (0%) of program storage space. Maximum is 253952 bytes.
Global variables use 188 bytes (2%) of dynamic memory,
leaving 8004 bytes ...
-1
votes
1
answer
627
views
Is low memory warning based on a fixed number of on the actual sketch?
I have the following output of my sketch for the Arduino Mega so far:
Sketch uses 25020 bytes (9%) of program storage space. Maximum is 253952 bytes.
Global variables use 6919 bytes (84%) of dynamic ...
1
vote
2
answers
111
views
Timestamping AnalogBinLogger data
I would like to timestamp the data collected from AnalogBinLogger.ino on an Arduino Uno. The sketch uses 512-byte buffers, and I have read that writing data in 512-byte chunks is 'better' in terms of ...
0
votes
1
answer
173
views
Memory usage in AnalogBinLogger of SdFat library
The AnalogBinLogger.ino file of SdFat library says the following:
Each 512 byte data block in the file has a four byte header followed by up to 508 bytes of data. (508 values in 8-bit mode or 254 ...