Pages: [1]   Go Down
Author Topic: Memory question ?  (Read 323 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 146
Posts: 5535
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

That would explain it.
« Last Edit: December 14, 2012, 01:13:44 pm by flak88 » Logged

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 67
Posts: 2710
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1]   Go Up
Jump to: