Memory in Solidity
Learn about the details of memory in Solidity.
We'll cover the following
Memory in Solidity serves as a storage area for variables defined within the scope of a function. Unlike storage
, memory
variables are temporary and only persist for the duration of the function call. They can’t be accessed outside the function scope, making them suitable for temporary data storage within functions.
It’s important to note that memory
variables are mutable within the function, allowing for dynamic manipulation. We can think of memory as the RAM in a laptop while the computer is operating. We can access any unsaved data, but as soon as it shuts down, any data that hasn’t been saved is deleted from RAM. Memory variables are used for short-term computations and storage.
Get hands-on with 1400+ tech skills courses.