I was reading Solidity's Layout in Memory docs, and I was rather surprised to learn that:
Solidity always places new objects at the free memory pointer and memory is never freed (this might change in the future).
I'm confused. Doesn't memory get flushed across contracts? Say you have an upgradeable proxy that delegate calls to an implementation contract. In this case, we use the "returndatasize" and "returndatacopy" EVM instructions to get hold of the return data. Aren't we doing that precisely because there is no other way to access the return data?
Furthermore, from the same doc:
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 lifetime, the pointer is not updated. The memory may or may not be zeroed out. Because of this, one should not expect the free memory to point to zeroed out memory.
So which one is it? Does Solidity free memory or not?