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 output is attached :

#include &lt;MemoryFree.h&gt;
void setup() 
{
  // put your setup code here, to run once:

  Serial.begin(9600); Serial.println(freeMemory(), DEC);  // print how much RAM is available.
  Serial.println("Lets Start");
}
void jack();
void loop() 
{
    char c=0;
    c++;
    Serial.println("");
    Serial.println("Rajat0");
    Serial.println(freeMemory(), DEC);
    Serial.println("Rajat1");
    int x=0;
    x++;
    Serial.println("Rajat2");
    Serial.println(freeMemory(), DEC);
    Serial.println("Rajat3");
    jack();
    Serial.println("");
    delay(1000);
}
void jack()
{
    Serial.println("jack0");   
    int x=0;
    x++;
    Serial.println(freeMemory(), DEC);
    Serial.println("jack1");      
}
You are assuming that, just because you created a variable, it will be stored in memory. That is often not the case.

The compiler is reasonably intelligent. And there are lots of CPU registers in the AVR core. If there is a free register available for a temporary local variable like that, why would it waste time and effort putting it into memory when it can just keep it in a register?

Also, since you don't really do anything with the variable, chances are the compiler is just throwing it away.

Marking a variable volatile will remove both those problems, and you may see different results.