The Byte is the standard unit of storage, made up of 8 bits (binary digits) whose state can be 1 or 0.
Bytes have been shown on the LHS of the diagram below to indicate that the memory area comprises of a huge number of these (many millions/billions, etc, according to the amount of storage available). The BIOS and the OS, just as any other program, require storage and have been shown here for completeness.
The main areas we are interested in is the data segment (collectively consisting of the code, data and bss), the stack and the heap.
The following diagram provides a simplified view of how the memory is laid out:
OS, environment variables, command line arguments
Works on a LIFO basis
Used for local variables and passing arguments to functions,
along with return address of the next instruction to be
executed when the function call is over
When a new stack frame needs to be added (as a result of
a new function), the stack grows downward
Unallocated. Free area, available to be utilised for growth by
heap or stack
(aka Free Store)
Used for Dynamic Memory allocation
C managed by malloc(), realloc(), free()
C++ managed by new, delete
BSS. Uninitialised data
Data segment. Initialised data. Global and static variables
Code segment. aka Text segment.
Contains the compiled Machine code (program) instructions.
Often r/o to stop it being overwritten.
*Note: this is greatly over simplified and shows just one program loaded in memory