Stacks grows from top to bottom. Stack segment is used to store all local variables and is used for passing arguments to the functions along with the return address of the instruction which is to be executed after the function call is over. Local variables have a scope to the block which they are defined in, they are created when control enters into the block. All recursive function calls are added to stack.
In order to support dynamic memory allocation heap is used, it may happen that we require some more memory then calculated so heap comes in picture
Text, data and BSS spaced is reserved during compile time itself.
Different OS uses space between stack and heap differently.
Space between heap and stack is contiguous most of the time, and is reserved. but if program want more space then allocated here comes heap into picture OS gives virtual memory to program, when ever there is need of physical memory the some data which is not currently in use is swapped in secondary memory and demand of program is fulfilled, after completion of task that data is swapped in into physical memory.
Stack segment is placed in physical address space of program