Skip to main content

Questions tagged [memory-usage]

Use this tag for questions about memory usage on the Arduino.

Filter by
Sorted by
Tagged with
1 vote
0 answers
34 views

"Stack canary watchpoint triggered (loopTask)" when synchronizing with Arduino Cloud IoT (ArduinoCloud.update())

I have created a sketch that updates 195 variables : 16xString variables, 34xfloat, 52xint, 107xbool. Notice : I'm using the IDE tool instead of the included Cloud IoT compile (because I have a pb ...
christophe Hanotte's user avatar
-1 votes
2 answers
222 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 ...
Hobbes's user avatar
  • 146
0 votes
1 answer
82 views

How can I make this function take up less memory? [duplicate]

I've written a sketch that uses TimeLib to display elapsed time. I'm measuring how long it takes to drain a battery. The goal is to display the time as hh:mm:ss. The code I use works well when I ...
Hobbes's user avatar
  • 146
0 votes
1 answer
67 views

Problem with char* variable malloc/free. Empty contents on recipient variable after using free

I am working on a custom SD card data logger using the following function and struct: char *filenameCreator(const char *prefix, const char *num, bool addExtension) { char *filename = (char *)...
Daniel Melendrez's user avatar
0 votes
1 answer
108 views

deserializeJson() failed: NoMemory when sending Serial json using ArduinoJson

Hey all I have a sketch that takes up 99% of my storage space since I am using a Arduino Nano. Although everything in my code fits as-is, there seems to be an issue with me sending a json string over ...
StealthRT's user avatar
  • 259
-1 votes
1 answer
84 views

Help reducing dynamic memory usage with LoRa library

I have combined code that reads heart rate and SPO2 then sends the data using LoRaWAN. Using these 2 libraries that work well by themselves LoraWAN lib | MAX30102 lib. My board is an Arduino Pro or ...
Inversionist's user avatar
0 votes
2 answers
94 views

Is it "safe" to use "new" keyword to instantize several sensor objects?

I've read that it is bad practice to use dynamic memory allocations on a microcontroller and I have a pretty good grasp of why. I am developing a custom PCB around an ATMega2560 and in my situation, I ...
MattD's user avatar
  • 3
1 vote
1 answer
217 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 ...
user1584421's user avatar
  • 1,415
1 vote
1 answer
318 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 ...
Gaai's user avatar
  • 55
2 votes
1 answer
217 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 ...
Ramanewbie's user avatar
-3 votes
1 answer
86 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, ...
Aravindh Vasu's user avatar
1 vote
2 answers
443 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 ...
RowanP's user avatar
  • 869
1 vote
0 answers
340 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 ...
gabor aron's user avatar
1 vote
1 answer
399 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 ...
Vitor Z.'s user avatar
3 votes
2 answers
791 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 ...
Daniel Williams's user avatar
2 votes
2 answers
458 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 ...
Boyfinn's user avatar
  • 245
1 vote
1 answer
854 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 ...
gurkensaas's user avatar
0 votes
1 answer
119 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 ...
LukasFun's user avatar
  • 295
3 votes
3 answers
897 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 ...
Ethan Braun's user avatar
1 vote
0 answers
426 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 ...
adrianton3's user avatar
1 vote
1 answer
248 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 ...
PMF's user avatar
  • 1,306
2 votes
3 answers
163 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 ...
Namra Noor's user avatar
2 votes
4 answers
258 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 ...
Michel Keijzers's user avatar
2 votes
2 answers
7k 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 , the error being could_not_allocate_required_memory. In my program, each time I ...
Androing's user avatar
3 votes
2 answers
612 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 ...
PMF's user avatar
  • 1,306
2 votes
2 answers
97 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 ...
none none's user avatar
  • 233
4 votes
1 answer
916 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 ...
Kevin Sullivan's user avatar
4 votes
1 answer
543 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 ...
WildCat's user avatar
  • 323
1 vote
2 answers
90 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: ...
Arseni Mourzenko's user avatar
2 votes
1 answer
309 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 ...
Valentino Zaffrani's user avatar
1 vote
0 answers
287 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 ...
Nina's user avatar
  • 185
1 vote
0 answers
60 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 ...
Juan's user avatar
  • 11
0 votes
1 answer
496 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 ...
DSP_engineer's user avatar
1 vote
0 answers
56 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 ...
B7th's user avatar
  • 167
1 vote
0 answers
471 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 ...
Tono Nam's user avatar
  • 938
12 votes
4 answers
8k 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 ...
Tono Nam's user avatar
  • 938
0 votes
1 answer
544 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 ...
Tono Nam's user avatar
  • 938
0 votes
1 answer
85 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 ...
Sam Ruben Abraham's user avatar
-3 votes
1 answer
2k 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 ...
e1065273's user avatar
1 vote
1 answer
458 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 ...
LeandroIP's user avatar
8 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 ...
Mayoogh Girish's user avatar
0 votes
1 answer
185 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 ...
Beacon of Wierd's user avatar
1 vote
2 answers
4k views

Serial printing from flash memory (F() macro, PROGMEM, sprintf_P, SPTR)

I have been testing various techniques on an Arduino Uno 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 ...
NickG's user avatar
  • 163
0 votes
2 answers
590 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(...
David Klempfner's user avatar
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 ...
Casey's user avatar
  • 151
1 vote
1 answer
802 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];...
Benjamin Jordan's user avatar
1 vote
2 answers
94 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() { ...
AnT stands with Russia's user avatar
0 votes
1 answer
65 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 ...
Noslen's user avatar
  • 19
1 vote
1 answer
806 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. ...
Salvador Adrián León Chávez's user avatar
0 votes
1 answer
156 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, ...
fredlcore's user avatar