⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠ You can decompress Drawing data with the command palette: ‘Decompress current Excalidraw file’. For more info check in plugin settings under ‘Saving’

Excalidraw Data

Text Elements

TL;DR: Different addresses meaning variable “a” in increment function is not pointing to same “a” in main function.

How this program runs? How this happen in computer’s memory when a program executes?

When a program or an application is started then the computer (or machine) set aside or reserves some amount of memory for the execution of this program.

Heap

Stack

Static / Global

Code (text)

Application Memory

Fixed when program starts

Program when asks for more memory during execution, Heap is allocated.

Stores various instructions in the program (e.g. increment)

Variables outside scope is global, can be used in any scope or anywhere during execution.

Local Functions & Variables are stored.

Memory allocated during runtime.

Computer Memory during execution