10
votes
Is using malloc() and free() a really bad idea on Arduino?
I disagree with people who think you shouldn't use it or it is generally unnecessary. I believe it can be dangerous if you don't know the ins and outs of it, but it is useful. I do have cases where I ...
9
votes
What's taking up so much RAM in an almost empty sketch?
I investigated this at some length a while back. On this page about putting constant data into program memory I obsessively tracked down every last byte of memory used in a small sketch. This was the ...
9
votes
Sizeof variables and Due's RAM
sizeof doesn't return the number of elements. It returns the number of bytes. Since they are uint16_t arrays each element is 2 bytes - hence twice the size.
The reason your last number is only 40928 ...
7
votes
Accepted
Executing machine code at runtime Uno
The microcontroller is executing one command at a time from..where?
Flash memory directly. The AVR core can only execute instructions from Flash memory. It uses a two-bus system known as Harvard ...
6
votes
Accepted
Arduino constant vs Microchip PIC constant
const means different things in different contexts as far as storage goes.
For a simple numeric value the compiler will generally replace the constant with the literal value. Any mathematics using ...
6
votes
Locally declared variable takes up global variable space in dynamic memory/SRAM
Isn't the space taken up by the local variable supposed to be freed up
from the SRAM once the functions runs because I have declared the
variable locally?
This is correct. The local arrays you ...
5
votes
Accepted
Why is my SRAM so quickly filled? There are not more than 60 bytes
When you are asking yourself what is eating so much RAM, the first step
is to look at the symbol table in the ELF file. If you use a makefile, you
probably know where to find the ELF file. If you are ...
5
votes
Measure SRAM usage
Expanding on my previous comment... The RAM memory map of an AVR-based
Arduino looks like this:
┌──────┬─────┬──────┬──────────┬───────┐
│ data │ bss │ heap │→ free ←│ stack │
└──────┴─────┴──────┴─...
5
votes
Accepted
Does the StringObject.reserve() function prevent memory fragmentation/leaks?
Reserving space will help reduce memory fragmentation, but much of what else you are doing is swamping that small improvement you have made.
The biggest area of concern is your cutString function, ...
5
votes
Locally declared variable takes up global variable space in dynamic memory/SRAM
You must declare the array in global space or static, and make sure the function you pass the buffer pointer to knows it is in PROGMEM.
void send22()
{
static unsigned int irSignal[] PROGMEM= {...
5
votes
Accepted
Is there a way to add external RAM (let's say 100 MB or 200 MB) in this audio buffer mixing context?
There are SRAM ICs / boards, however, don't expect 100 MB, more like 1 MB (with the pin numbers and connectivity / protocols that an Arduino offers).
With Flash you can get much further, but it can ...
5
votes
Serial printing from Flash Memory (F() macro, PROGMEM, sprintf_P, SPTR)
First, the freeMemory() function that you used from Adafruit was originated from a github, I don't know about the __arm__ implementation, but for the avr, it is incomplete for handling the corner case ...
4
votes
Is using malloc() and free() a really bad idea on Arduino?
Is it a really bad idea to use malloc() and free() with Arduino?
The short answer is yes. Below are the reasons why:
It is all about understanding what an MPU is and how to program within the ...
4
votes
Accepted
Array + Serial Monitor Problem
Use the F() macro for all double-quoted strings you print. Change lines like this:
Serial.println(" degC.");
...to this:
Serial.println( F(" degC.") );
This will save about 100 bytes of RAM.
And ...
4
votes
Array + Serial Monitor Problem
You have likely run out of RAM.
You have 431 integers in the look-up table alone. That equates to 862 bytes of SRAM. You also have a buffer of 75 floats, which equates to 300 bytes. This is in ...
4
votes
Why is my SRAM so quickly filled? There are not more than 60 bytes
To elaborate on Edgar Bonet's answer and my comment under it, you cannot usefully put PROGMEM variables as local variables because local (non-static) variables have to be allocated on the stack.
void ...
4
votes
Confusion with storage of declared variables and volatile
That's just plain incorrect.
The volatile keyword tells the compiler that the value of that variable may change at any time, and that therefore it must re-read the value every time you use it in your ...
4
votes
Accepted
Which library to use for 23LC1024 SRAM 1 Mbit
SPI RAM has two modes of operation: single byte and "page mode".
In single-byte mode you first send the read or write command followed by the (typically 3-byte) address and then read a byte. That's 5 ...
4
votes
Can I make existing libraries use external SRAM for the Arduino
Making a library use external SRAM is not an easy task. It can be cone, but it takes quite a bit of work.
The best start would be to abstract the SRAM into a library that provides simple access to it....
4
votes
Sizeof variables and Due's RAM
The sizeof operator's result is number of bytes, not number of array elements. Your arrays in the program above have two bytes per element, hence twice as many bytes as elements.
If you want to ...
4
votes
Accepted
Is SRAM erased when putting Arduino into sleep_mode_pwr_down?
Generally, Atmega sleep modes do not erase RAM. Their memory is static and as long as voltage (above 2.7V I believe) is applied, data is held.
However, this also depends on how you plan to wake up ...
4
votes
Accepted
Does the bootloader use some SRAM?
You did not specify what type of Arduino you are using. My answer is for
the AVR-based ones.
The bootloader does use RAM while it is running. However, once it
handles control to your program, the ...
3
votes
Is there any way I can connect the RAM of a computer to Arduino?
No, you can't connect your normal desktop computer memory to your Arduino. For a number of reasons:
Computer memory (at least for the past 20 years) is DDR SDRAM. That's Synchronous Dynamic RAM. It ...
3
votes
Inherent delay running EEPROM.read()
When I store it in the EEPROM, the extra time required to find it in EEPROM, pull it through the sketch, and then push it through to the db corrupts the data sourced from EEPROM and posts a jumbled ...
3
votes
Forensic security of Arduino (SRAM)
RAM memory looses its contents when it's powered off. However, this
natural erasure process is not instantaneous: it can take several
seconds, or even minutes. It has been demonstrated that cooling ...
3
votes
How to write data in RAM memory using Arduino Uno or Arduino Due?
Your program is already using the on board RAM:
int a = 5; // This is RAM. Where did you think it goes? (This might go to a CPU Reg)
int a[5000]; // This is RAM
DDR3 RAMs require (typically) 1633 ...
3
votes
How to write data in RAM memory using Arduino Uno or Arduino Due?
DRAM of any kind requires a memory controller which is not present in any AVR device. Larger AVR devices such as the ATmega64A and ATmega128A do have an external memory bus that can be used for SRAM ...
3
votes
Accepted
Local variable usage in SRAM not counted
Why is the local variable not counted?
Let us start with the function availableMemory(), what does it do?
int availableMemory()
{
extern int __heap_start, *__brkval;
int v;
return (int) &...
3
votes
Which library to use for 23LC1024 SRAM 1 Mbit
This was an excellent challenge for an SPI bus manager and device driver support library I have been working on. Below are some performance results for the SRAM (23LC1024) device driver (Arduino Uno @ ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
sram × 60arduino-uno × 24
memory-usage × 16
memory × 11
programming × 6
c++ × 5
spi × 5
arduino-due × 5
array × 5
eeprom × 5
variables × 5
progmem × 5
serial × 4
arduino-mega × 3
flash × 3
wifi × 2
atmega328 × 2
sd-card × 2
string × 2
sketch × 2
sensors × 1
arduino-nano × 1
power × 1
led × 1
bluetooth × 1