Questions tagged [memory-usage]

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

Filter by
Sorted by
Tagged with
-1
votes
1answer
33 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 ...
0
votes
1answer
34 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 ...
5
votes
4answers
2k 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
1answer
45 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
2answers
70 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
2answers
26 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(...
3
votes
4answers
482 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
1answer
28 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
2answers
66 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
1answer
57 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
1answer
68 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
1answer
46 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
0answers
139 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 ...
4
votes
2answers
178 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 ...
1
vote
1answer
51 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 ...
0
votes
1answer
144 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 ...
0
votes
2answers
45 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
1answer
97 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 ...
1
vote
1answer
38 views

Maximum Capacity Debugging

1. Example Check the program below for an Arduino Nano, Old Bootloader, for variable values of N. For low values (N<=1857), the program outputs "[FFFFFFFF]", For higher values (1858<=N<=...
0
votes
1answer
37 views

Dynamic memory 'new' (of an overridden class) call affects SRAM memory

I have made a quite large program (not executed at an Arduino lately). However, if I compile with the next fragment: void LightSetupClass::CreateFixtures() { for (fixture_number_t fixtureNumber =...
1
vote
2answers
56 views

Is new without a delete acceptable?

I know it is not a good practice to use the new command to dynamically create data, however, if I would never use the delete, would it result in memory gaps/other problems? Background The reason I ...
1
vote
1answer
26 views

Is new.cpp programmed improperly? Arduino 1.8.9

I'm having trouble with my code and I'm not sure if it's a memory allocation issue. So I look at the new, delete to see if it throws errors, and finding the source code I find outrageously simple ...
4
votes
3answers
2k views

Memory usage: #define vs. static const for uint8_t

I'm writing an Arduino library to communicate with an I2C device, and I'm wondering what the best way is to declare all the register addresses so as to save memory. Using #defines: #define ...
2
votes
1answer
1k views

I need help with U8GLIB library

I have a project which uses a 128x64 oled display. I have to use the U8GLIB as the available displays change from SSD1306 to SSH1106 depending on when you buy it which that library covers both ...
1
vote
2answers
204 views

Memory problem? dtostr() and strcat()

I've been dealing with this for quite a while now and searching all over for answers.. I'm trying to put together two floats into a char*. Separated by a ",". This is the code I'm working with. #...
0
votes
0answers
85 views

Radio tx/rx makes my oled screen not work

I've been struggeling with this assignment for school for a couple of days. I have finally figured out where the problem lies. I have an oled screen that is supposed to print out the temperature of a ...
1
vote
1answer
883 views

How can I reduce the memory usage on my code?

I wrote this code to control my christmas tree. It takes up the majority of the memory on my Arduino Uno: Sketch uses 31822 bytes (98%) of program storage space. Maximum is 32256 bytes. Global ...
1
vote
0answers
96 views

Storing an array of objects

I followed the instructions of this post: Storing an array of function pointers. To show my problem I shorted my code extremely but the problem is still there. My classes are defined as followes: ...
3
votes
4answers
265 views

Can you help me trim my code?

First of all I want to be clear, I'm not very skilled in programming methods, all the C I learned was for various Arduino projects. That being said, I just finished a project that reads some data ...
0
votes
1answer
469 views

Pointer memory allocation in function

I would like to know how Arduino allocate memory for pointers in function arguments. For instance. I have this code that use 192 bytes (Arduino IDE compiler: Global variables use 192 bytes (9%) of ...
0
votes
2answers
451 views

freeMemory() function from memoryfree library not returning decreased value in arduino UNO

I burned the code written below, I expect that as we declare the local variable in the loop, freeMemory() function should return decreased value. But it remains constant..! please explain why..? The ...
0
votes
1answer
67 views

MemoryFree library showing Irregular Behaviour..!

I simply burned the code written below but it is showing me irregular behaviour.. as in output's last paragraph, free memory increases after a runtime allocation, how it is possible? The output is ...
1
vote
2answers
949 views

Best practice to declare a 'static' text and save memory

I'm working on a project where I need to create a JSON to send back state of an object. I created the code to achieve it and all works fine, but I used this to declare the JSON fields: static const ...
2
votes
1answer
404 views

Sending >255 bytes array to arduino

I am trying to send a 50x50 bitmap bytearray from my python client to arduino where it should be displayed on a screen. I need to receive 350 bytes to have the data to show the bitmap but as soon as ...
0
votes
3answers
81 views

storage problem

I made a Arduino program to control my air conditioner(model:GREE Lomo) by PC. I download IRremote library from here for that. #include "IRremote.h" IRsend irsend; int irPin = 3; // pin IR led int ...
1
vote
1answer
54 views

Runtime Error when using array of structs of unknown size as variable within class - some kind of overflow issue?

I have a class defined as below, it's basically a simple ring buffer, with some methods for getting useful statistics from the data held in the buffer. enum BalanceMsgType{ BAL_MSG_NOT = 0, ...
0
votes
1answer
184 views

How to read main code inside main code in Arduino?

How can I read the hex code of the main programme stored inside flash memory inside my running Arduino programme? So far I am able to read the Flash at any given address by using PROGMEM unsigned ...
5
votes
3answers
3k views

When to use PROGMEM?

I believe PROGMEM is used to store large data (e.g. strings) that don't change. So it frees up the SRAM. in the Ardunio Reference it is mentioned that. "Using PROGMEM is also a two-step procedure. ...
8
votes
2answers
1k views

memory usage “dos and don'ts”

Though I've written C/C++ code for a long time, the unseen limitations on how memory was consumed on various MCU and SOC programming platforms have often tripped me up. As I'm about to build up code ...
2
votes
3answers
723 views

Reducing Memory Usage lots of Floats

Im using an Arduino Uno - All code at github.com/robbrad/AirQuality Current sketch usage: Sketch uses 23186 bytes (71%) of program storage space. Maximum is 32256 bytes. Global variables use 1428 ...
0
votes
2answers
92 views

What values are the Atmel MCUs EEPROMs preloaded with?

I have checked with two datasheets: one for some ATMegas and one for some ATTinys MCUs and could not find what the EEPROM.get() call would read back if the EEPROM was empty (or contained default ...
1
vote
2answers
1k views

Const data optimisation for Arduino

I'm taking a course on Arduino Uno programming and on today's talk I heard that the const data is optimized by Arduino, so that it occupies less space than the actual data type (namely, a const int ...
2
votes
3answers
514 views

Is it possible to configure FRAM memory for use as stack and heap?

I'm using the Adafruit I2C FRAM breakout board with my Nano and it works as advertised, but every time I write a variable to this thing I have to use library function calls with addressing. This makes ...
2
votes
2answers
355 views

Lowest memory consumption for arrays

I made a little joystick input recorder that stores the joystick state (8 directions + fire) and the time (how long was a button or direction pressed). Example data would be like this (i = input, t = ...
2
votes
1answer
7k views

String to persistent memory (EEPROM?)

I am creating a server node that I want to be able to save the wifi SSID and the password into persistent memory so that when it starts ups it can connect to the network. I have looked for several ...
0
votes
2answers
420 views

What are safe memory usage limits?

The Arduino IDE used to warn you when your sketch used too much memory. This warning now seems to have been removed. I compiled a sketch, and was surprised to see it use 175% of data memory...but not ...
0
votes
2answers
145 views

Is the use of malloc() and free() necessary in my Kalman noise Filter function?

I had a code that implements Kalman noise filtering on Arduino, and there is a use of malloc() and free(). I'm wondering if this will affect the Arduino or not (for example, the program will not ...
0
votes
3answers
781 views

Arduino constant vs Microchip PIC constant

2.2 THE BASICS OF C PROGRAMMING LANGUAGE book is has like this, CONSTANTS A constant is a number or a character having fixed value that cannot be changed during program execution. Unlike variables, ...
0
votes
2answers
91 views

Sketch Memory in Pro

void storedata(File filename ,int type , String data) { if(type == 1){ Serial.println("Group Creation"); } //Storing Data into file pinMode(10, OUTPUT); if (!SD.begin(...
3
votes
1answer
126 views

Local variable usage in SRAM not counted

I use the following code to print the currently used SRAM space: // this function will return the number of bytes currently free in RAM // written by David A. Mellis // based on code by Rob Faludi ...