2011年9月5日 星期一

Memory layout for a process

Address space is memory space that contains program code, stack, and data segments or in other word, all data the program uses as it runs.  The memory layout, typically consists of three segments (text, data, and stack), in simplified form is shown in Figure 4. The dynamic data segment is also referred to as the heap, the place dynamically allocated memory (such as from malloc() and new) comes from. Dynamically allocated memory is memory allocated at run time instead of compile/link time.  This organization enables any division of the dynamically allocated memory between the heap (explicitly) and the stack (implicitly). This explains why the stack grows downward and heap grows upward.

沒有留言:

張貼留言