WhatMeWorry
2006.06.05, 05:19 PM
Ok, I know about stack memory where arguments to functions are
pushed upon entry and popped upon exit. I also understand heap
memory (dynamic memory) where it is allocated and released explicitly
by commands in one's program: malloc/free in C; new/free in C++.
But where do global variables fit into the picture. Is the entire application
considered one big function whose globals are pushed at program startup
and popped at program exit?
And while I'm on the subject, how about static variables in C. They appear
inside a function, but their values are retained from call to call. Are these
in the heap memory since their values are retained?
pushed upon entry and popped upon exit. I also understand heap
memory (dynamic memory) where it is allocated and released explicitly
by commands in one's program: malloc/free in C; new/free in C++.
But where do global variables fit into the picture. Is the entire application
considered one big function whose globals are pushed at program startup
and popped at program exit?
And while I'm on the subject, how about static variables in C. They appear
inside a function, but their values are retained from call to call. Are these
in the heap memory since their values are retained?