Let's say I have a dynamic array of some length and I want to push a new element, but memory after last elem is already used.
What would happen in such case? Compiler would find a new 'chunk' of memory that can hold an array and copy it there or something else? And if yes, how this new address would be calculated?
Also, as I know, dynamic arrays in solidity works like mappings in some way, I mean each item of the array is laid out sequentially from address that is calculated with hash of array variable address:
And if memory was reallocated, how would solidity find this variable's new location? We don't store any pointers, just calculating hash.