diff options
author | chriseth <chris@ethereum.org> | 2016-10-14 17:13:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-14 17:13:36 +0800 |
commit | 0635b6e008fc9eaa6e96d91101e420012db6bb83 (patch) | |
tree | 4fcbf0f8253c274bb9a841846ca2b8d1da81efb3 /docs/miscellaneous.rst | |
parent | d9af51be51f98c652e262444dc9e4ad2b5110cc8 (diff) | |
parent | 9521188bde4385e5131446b3e3eb7a9bdda37504 (diff) | |
download | dexon-solidity-0635b6e008fc9eaa6e96d91101e420012db6bb83.tar dexon-solidity-0635b6e008fc9eaa6e96d91101e420012db6bb83.tar.gz dexon-solidity-0635b6e008fc9eaa6e96d91101e420012db6bb83.tar.bz2 dexon-solidity-0635b6e008fc9eaa6e96d91101e420012db6bb83.tar.lz dexon-solidity-0635b6e008fc9eaa6e96d91101e420012db6bb83.tar.xz dexon-solidity-0635b6e008fc9eaa6e96d91101e420012db6bb83.tar.zst dexon-solidity-0635b6e008fc9eaa6e96d91101e420012db6bb83.zip |
Merge pull request #1195 from ethereum/memory-doc
Document memory layout
Diffstat (limited to 'docs/miscellaneous.rst')
-rw-r--r-- | docs/miscellaneous.rst | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/docs/miscellaneous.rst b/docs/miscellaneous.rst index d32186ca..72e32617 100644 --- a/docs/miscellaneous.rst +++ b/docs/miscellaneous.rst @@ -56,6 +56,23 @@ So for the following contract snippet:: The position of ``data[4][9].b`` is at ``keccak256(uint256(9) . keccak256(uint256(4) . uint256(1))) + 1``. +**************** +Layout in Memory +**************** + +Solidity reserves three 256-bit slots: +- 0 - 64: scratch space for hashing methods +- 64 - 96: currently allocated memory size (aka. free memory pointer) + +Scratch space can be used between statements (ie. within inline assembly). + +Solidity always places new objects at the free memory pointer and memory is never freed (this might change in the future). + +.. warning:: + There are some operations in Solidity that need a temporary memory area larger than 64 bytes and therefore will not fit into the scratch space. They will be placed where the free memory points to, but given their short lifecycle, the pointer is not updated. The memory may or may not be zeroed out. Because of this, one shouldn't expect the free memory to be zeroed out. + +.. index: memory layout + ***************** Esoteric Features ***************** |