Go Down

Topic: Lack of SRAM memory (Read 3216 times) previous topic - next topic


you're right i know that but write it wrong...  :smiley-red:


I'm sorry that I am not answering your question, but I have found a library that tells you how much SRAM you have left. It could be useful in the future for diagnosing problems causeb by the lack of SRAM: http://playground.arduino.cc/Code/AvailableMemory.


you're right i know that but write it wrong...  :smiley-red:

I speak logic.  The code is
Code: [Select]
noMes[carmes - '0' + 1]

If carmes is '0' then the index will be 1 because of the + 1. You waste noMes[0] and must have an extra noMes[] to hold the last because the + 1 moves all up by 1, you see?

int Arry[ 4 ] = { 1, 2, 3, 4 };
Arry[0] == 1
Arry[3] == 4

for ( byte i = 0; i < 4; i++ )
  Serial.println( Arry[ i ] );

will print
Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts


Just a couple of thoughts. First off, this doesn't look good to me, as it indicates
almost all of the Flash in the chip [I assume it's a UNO] has been used up, unless
I'm reading it wrong.
(Flash memory is good: 31.030 bytes).

Secondly, personally I don't see much in the code posted originally to indicate the
strings use up very much RAM. I would think that more likely the libraries being
called are the bad boys. Do you know what size RAM buffers each of them uses?
Code: [Select]
#include <SPI.h>
#include <Ethernet.h>
#include <VirtualWire.h>
#include <Wire.h>
#include "SdFatUtil.h"


dc42 thank you very much, i will look to do what you have recommended.
3. You use the same string literal several times, for example ".csv", "%s%s" and " , ". Depending on whether gcc is performing string pooling or not, you might save memory by naming string literals that you use more than once.

You're telling to use like
Code: [Select]
char name[]=".csv" and everytime i need to "write" that i point to "name" char. Is this?

I'm suggesting that may save memory - it depends on whether gcc is using string pooling both in flash and in RAM when it is invoked from the Arduino IDE. Try it on a few strings to see whether it saves any memory before you spend time applying it on the whole program. You should always use "const char*" instead of "char*" when naming string literals.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Go Up