I've been looking through the code of Etherdice and noticed that some variables are declared like
ParserResult memory result;
and I haven't found the keyword "memory" in any documentation.
What I found on here was this explanation:
They are analogous to memory and hard drive storage in a computer. The
contract can use any amount of memory (as long as it can pay for it of
course) during executing its code, but when execution stops, the
entire content of the memory is wiped, and the next execution will
start fresh. The storage on the other hand is persisted into the
blockchain itself, so the next time the contract executes some code,
it has access too all the data it previously stored into its storage
area.
Does the "memory" declaration actually make the value be stored in "memory"? Aren't all local variables inside a function stored just in memory and global variables always stored in the blockchain? And what is the relation to this explanation of "Memory" here?
Best Answer
The Solidity FAQ on "memory" is highly recommended reading in entirety, and a snippet is provided below.
The FAQ has code samples to help explain further.
The subtleties explanation of memory explains gas costs for using memory, which is a byte-array that "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".