title: How to get the memory size of a dynamic array?
body: <p>In Delphi, you can get the size of a value type with the <code>sizeof()</code> compiler magic function, but calling <code>sizeof()</code> on a reference type will give you the size of a pointer, not of the value it's pointing to.</p>
  
  <p>For objects, you can get the memory size with the <code>InstanceSize</code> method, but what about for dynamic arrays?  Due to padding, <code>length(MyArray) * sizeof(element)</code> may not be accurate.  So, is there any accurate way to get the memory size of a dynamic array?</p>