Stack memory existence

where does the stack memory exist? If in RAM, then precisely where?

Hi deepanshu , to explain you about stack memory I will first briefly talk about a process, process is a program in execution now whenever you run your program , say main.cpp, this program is loaded into the memory and it becomes a process, operating system divides the process into four sections ─ stack, heap, text and data.
In Stack the allocation happens on contiguous blocks of memory. We call it stack memory allocation because the allocation happens in function call stack. The size of memory to be allocated is known to compiler and whenever a function is called, its variables get memory allocated on the stack. And whenever the function call is over, the memory for the variables is deallocated.

Now you wish to know where in RAM , so every process is allocated some memory from RAM which gets divided into above mentioned parts, there is no fixed partition or area in RAM from where this memory is allocated from, OS searches a memory block in RAM and allocates the memory to the process that all it is .

In case of any doubt feel free to ask :slight_smile:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.