This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Global Vs Local Variable

I have all global variables in my project. Since RAM data size has almost become full, i wanted to replace some of the global variables with local variables in functions. But each local variable declaration seems to take up RAM space as if it is a global variable;

Assume I have few global variables and the data size is 10 bytes

now i add a new function

void function1()
{
char var1,var2,var3,var4,var4,var5,var6,var7,var8,var9,var10;
}

this increases the data size to 20.

adding another function

void function2()
{
char var1,var2,var3,var4,var4,var5,var6,var7,var8,var9,var10;
}

this again increases the data size to 30. What is the point of using local variables in this scenario? It works as if the the variables are declared globally. Shouldn't the data size be global variables 10 bytes + maximum local variable size i.e 10 bytes?