In fact, length(MyArray) * sizeof(element) will be accurate for the contents of the array, excluding any internal dynamic array or string.
If you want the entire array to use memory, including the size of the contents of nested reference types, you can use our TDynArray wrapper. It is able to serialize into binary any dynamic array, including reference counted elements (for example, dynamic arrays or strings). You have SaveTo / SaveToStream for this purpose, and you can get the actual size of all the content.
Take a look at this blog post that introduces this shell. It runs open source and runs from Delphi 5 to XE4, both on the Win32 platform and on Win64.
source share