When an array is declared in this form, the memory is allocated statically:
var
Data: array[0..5] of integer;
My question is when the array is declared in the following way:
var
Data: array of integer;
....
SetLength( Data, Length( Data ) + 1 );
Is the memory allocated statically or dynamically?
I think that the memory is allocated statically and the array is copied in memory, but I am not certain.
This is dynamic allocation, for three reasons:
Length( Data ) + 1
depends on information that's only known at runtime, it can't be allocated statically.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With