In this track: Storage, memory and layout
advanced · 4 MIN READ

The free memory pointer

Solidity stores its allocation pointer at memory address 0x40.

LET’S PICTURE IT

A bookmark identifies where the next managed workspace allocation should begin.

SEE IT FOR YOURSELF
Use temporary memory in one execution frameStep 1 / 4
Use temporary memory in one execution framePointer wordmemory address 0x40value: 0x80Working areabegins at 0x80not a storage slotCompiler memory conventions differ from persistent storage layoutValue 42hex: 0x2aleft-padded in a wordMSTOREoffset 0x80bytes 0x80–0x9fA retained manual allocation must also maintain the memory pointerMLOADoffset 0x80read 32 bytesStack result42same stored wordMLOAD and SLOAD access different data locationsRETURN rangeoffset 0x80size 32 bytesOutput bytesencoded integer 42caller interprets schemaEach message-call frame has its own memory working space

This frame uses temporary byte-addressed memory. Solidity normally keeps a free memory pointer at address 0x40, initially pointing to 0x80.

Animated local teaching model. No wallet, RPC or live blockchain data. Some labels and hashes are abbreviated for readability.

Distinguish pointer location and value

The memory word at address 0x40 holds the free memory pointer. The address 0x40 and the pointer value stored there are different numbers.

Recognize the conventional initial value

Solidity normally initializes the pointer to 0x80 after reserved scratch, pointer and zero-slot regions. This is a compiler memory convention, not a universal EVM opcode rule.

Do not assume pointed bytes are zero

Temporary compiler operations can use memory around the pointer without permanently advancing it. The pointer alone is not a promise that the referenced region contains zeros.

Coordinate manual allocation

Assembly that retains newly allocated memory must follow the applicable memory conventions and advance the pointer appropriately. Incorrect bookkeeping can corrupt later compiler-managed values.

Inspect the layout

mload(0x40) // read the pointer value
// Usually 0x80 at initial Solidity setup.
// 0x60–0x7f is the reserved zero slot.

A convention sketch; it is not a complete memory allocator.

TURN UNDERSTANDING INTO PRACTICEOpen the Storage layout →
QUICK CHECK · NO PRESSURE

What is stored at memory address 0x40 under Solidity’s convention?

Your progress stays in this browser.
Keep exploring the original referenceSolidity documentation ↗

Original explanations by EtherTools. Examples are educational and source-linked; this site is independent of the Ethereum Foundation. Our approach.