Member-only story
Solidity Tutorial: All About Memory
Understanding the short term memory of the EVM
This is Part II of the “All About Data Locations” sub-series.
We will learn the layout of the EVM memory, its reserved spaces, the free memory pointer, how to use memory
references to read and write from/to memory and the conventional best practices when working with memory.
We will use code snippets of the contracts from the Ethereum Name Service (ENS) to support this article with meaningful examples. This will help us understand better how the smart contracts behind this popular project work under the hood.
Table of Content
- Introduction
- The EVM Memory — Overview
- Layout of Memory
- Basics of Memory
- Reading from Memory (
MLOAD
) - Writing to Memory (
MSTORE
+MSTORE8
) - Knowing the Memory Size (
MSIZE
) - The Free memory pointer
memory
references as functions parametersmemory
references inside functions body- The Memory Expansion cost
- Memory between contract calls
- Conclusion