Tuesday, 6 August 2013

How are the size of the stack and heap limited by the OS?

How are the size of the stack and heap limited by the OS?

Note: if you need to consider a specific OS to be able to answer, please
consider Linux.
Whenever I run a program, it will be given a virtual memory space to run
in, with an area for its stack and one for its heap.
Question 1: do the stack and the heap have a static size limit (e.g., 2
gigabytes each), or is this limit dynamic, changing according to the
memory allocations during the execution of the program (i.e., 4 gigabytes
total to be used by both, so if a program only uses the stack, it will be
able to have a stack with 4 gigabytes)?
Question 2: How is the limit defined? Is it the total available RAM memory?
Question 3: What about the text (code) and data sections, how are they
limited?
Thanks

No comments:

Post a Comment