After all these years of coding i just noticed this today, which is what blows my mind.
In a nut shell why does the ram usage calculate properly if i create a global array, but if i then add another array inside a function it does not take this into account as well.
If i create a global array, such as:
Code: Select all
char buff[1024];
void main(void)
{
}
Now here is where the problem comes in for me. Say i now do this.
Code: Select all
char buff[1024];
void MyFunction(void)
{
char buffer[4096];
buffer[0] = 0;
}
void main(void)
{
MyFunction();
}
In my mind when i see this issue of the ram size not increasing i am thinking this: Say we inherited a project from another user with 20-40 .cpp files. We were told just to add one small change to it. At this point becuase the ram is not increasing in size when using arrays inside a function how can we as the programmer know if we are actually going to be reading / writing data into some other variable space.
If this was pointers i would totally get it because the compiler does not know how much i want to store, but with an array it knows because i told it when i created the array.