Process memory layout

Thanks to the abstraction created by the use of virtual memory, all processes have the same memory layout.

Static memory segments

Data allocated to static memory segments is part of the object file, in other words, it increases the size of the executable file (see https://blog.bytecode.tech/this-would-not-happen-with-java/)

BBS (Block Started by Symbol) segment

Uninitialised (or initialised to 0) global variables

Data segment

Initialised global variables

Text segment

Code of the program

Dynamic memory segments

Data is allocated to dynamic memory segments at runtime

Stack segment

Data allocation to the stack segment is handled automatically by the process , although there is also an API to interact with the stack

Heap segment

Management of the heap segment requires its own API