How can I get the total memory size of a Jagged Array

seany seany at uni-bonn.de
Mon Nov 13 14:15:31 UTC 2023


Hello


Let's assume, that we have a string array : string[] sa;

I fill up the array with random strings with random lengths.

I want to know how much space it occupies in memory.

I could go over the string array using a for loop, then another 
loop for each character, and then sum up char.sizeof. But this 
would be very slow and inefficient.

Is there a better way? I want a method that works for every 
variable type including classes and objects.

Thank you




More information about the Digitalmars-d-learn mailing list