Memory
Last updated
Last updated
The memory of a running process is typically grouped into sections as shown below:
The Text segment holds the program instructions as well as any read-only data (e.g., strings).
The Data segment holds initialized data, so initialized global and static variables. Contrary to the text segment, this segment is not read-only, as the contents may be changed during execution.
The BSS segment holds uninitialized data. The segment is initialized to zero before the program starts executing. It typically holds global or static variables that are either uninitialized or initialized to zero.
The Heap memory is dynamically allocated program memory. It is managed through the brk
and sbrk
system calls, or, more commonly, through the suite of malloc
library functions. Memory in this segment can be allocated and released at runtime.
You will need to work with heap memory in the second part of Assignment 4+.
The Stack is a LIFO structure, growing from higher to lower addresses. It is used, among others, for local variables, return addresses, and temporary storage. The rsp
register keeps track of the top of the stack, while the rbp
register denotes the bottom of the current stack frame.
You will actively work with the stack starting from Assignment 2.