answersLogoWhite

0

Call-stacks are fixed-length and are allocated on a per-thread basis as threads are instantiated. The stack pointer CPU register keeps track of the next available address in the current thread's stack. The compiler computes the length of a function according to the number and type of its local variables (including formal arguments) plus the return address. When the function is invoked, the current stack pointer is adjusted by this amount, creating a "stack frame" specific to that function. Given the start address of the stack frame, the local variables and formal arguments can be referred to via constant offsets within the stack frame. When the function returns, the stack pointer is readjusted, effectively freeing the memory without actually releasing it back to the system. In this way, memory can be allocated and released on the stack with minimum cost.

User Avatar

Wiki User

8y ago

What else can I help you with?

Related Questions

Where does Local Variables get stored in?

Stack.


Local Variables will get stored in?

Stack.


Where auto variables are stored?

Auto variables are stored on the stack alongside all other local variables.


Where local variables are stored in c?

On the stack.


Where do register variables get stored?

Either in registers or on the stack.


Can variables be changed?

A static variable is one which is not stored on the stack but in the memory of the program. Static variables can be changed.


Local Variables is stored in which part of the memory?

RAM = Random Access Memory


Where static variables stored?

they are stored in the memory.they obviously can't be stored in stack Bcoz there value won't be retained between function call.


What are primitive variables?

Primitive variables are variables that are not objects and carry primitive values like numbers, boolean etc. The primitive data types in java are:intbytefloatcharlongbooleanshortdouble


Where the local variables will be stored?

When you declare a variable and it's data type in a function, it is stored in the specific space for memory allocated by the variable type identifier known as the "stack."


When you compile source code where the variables stored?

When you compile source code, the variables are stored in memory during program execution. The compiler translates the source code into machine code, which allocates memory for variables in different segments, such as the stack (for local variables) and the heap (for dynamically allocated memory). The specific location and management of these variables depend on the programming language, the compiler, and the architecture of the system. Additionally, constants and global variables may be stored in separate memory regions.


What is the storage allocation and scope of global extern static local and register variables?

AnswerLocal Variables are stored in Stack. Register variables are stored in Register. Global variables are stored in data segment. The memory created dynamically are stored in Heap And the C program instructions get stored in code segment and the extern variables also stored in data segment. Nooo NoooStatic variable will be stored in .BSS segment... (Block Started By Symbol)