Make delicious recipes!

Memory Structure of Programs


A program when loaded into memory has the following structure:

  1. Text Segment: Contains executable instructions of the program. It’s a read-only section.

  2. Initialized Data Segment: Contains global/static variables and is further divided as:

    1. Read-only literals like “Some string”

    2. Writable globals and static variables.

  3. Uninitialized Data Segment: Contains global and static variables too but those which have not been initialized. Usually, they are initialized to 0.

  4. Stack: This is where all the temporary and local variables are stored.

  5. Heap: This is where all the dynamically allocated variables are stored.


Heap and stack grow opposite to each other and if they grow so much that they meet or tend to overshoot each other, then it results in memory problem usually leading to emergency termination of the program by the OS.




Like us on Facebook to remain in touch
with the latest in technology and tutorials!


Got a thought to share or found a
bug in the code?
We'd love to hear from you:

Name:
Email: (Your email is not shared with anybody)
Comment:

Facebook comments:

Site Owner: Sachin Goyal