Ethereum Memory

Return to Glossary

Ethereum Memory (or Memory) is a byte-array. Memory starts off zero-size, but can be expanded in 32-byte chunks by simply accessing or storing memory at indices greater than its current size. Since memory is contiguous, it does save gas to keep it packed and shrink its size, instead of having large patches of zeros. It's cheaper to have an array of length 2 storing 2 values, than an array of length 1000 where the values are at the ends of the array and the middle is all zeros.

See: Ethereum Storage

Source: https://ethereum.stackexchange.com/questions/1232/difference-between-memory-and-storage/1235