Go Down

Topic: Memory question ? (Read 374 times) previous topic - next topic

flak88

I have a atmega 328 and have been trying to follow the guide to finding out how much ram is being used at any given time for debug purposes.However in the serial monitor im getting 1824 bytes with the char array declared and with it commented out which is very confusing.

Any ideas whats going on ?

Im using the libary from here and the example sketch from here:
http://playground.arduino.cc//Code/AvailableMemory

Code: [Select]

#include <MemoryFree.h>

// 14-bytes string
//char str[] = "Hello, world!";


void setup() {
    Serial.begin(115200);
}


void loop() {
    //Serial.println(str);

    Serial.print("freeMemory()=");
    Serial.println(freeMemory());

    delay(1000);
}




Cheers

fungus

The compiler discards it unless you actually use it in your program...?
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

flak88

#2
Dec 14, 2012, 07:11 pm Last Edit: Dec 14, 2012, 07:13 pm by flak88 Reason: 1
T

The compiler discards it unless you actually use it in your program...?

That would explain it.

bperrybap


The compiler discards it unless you actually use it in your program...?


Actually it is the linker.
The compiler can know if it referenced in a single source module but only
the linker can know if it were to be referenced in some other module.

--- bill

Go Up