[fpc-devel] Array of Ansistring
Bram Kuijvenhoven
kuifwaremailinglists at xs4all.nl
Mon Mar 12 14:38:48 CET 2007
Jason P Sage wrote:
> MyArray: Array of ansistring;
>
> There is code I saw that seems to work great using:
>
> SetLength(MyArray,100);
>
> Which allows MyArray[100]:='Some ansiString';
Dynamic arrays start at index 0 up to Length-1, so actually this code would corrupt memory ;) (but I assume this is a typo in your mail)
> What I don't know is how to clean this up.
It is cleaned automatically when the array goes out of scope (taking into account the refcounting of the dyn array itself), but of course also when you explicitly set the strings to '' or the array length to 0, as you proposed already. As Marco says, memory is usually not directly released back to the OS. BTW, memleaks can also be checked for with the heaptrc unit.
Regards,
Bram
More information about the fpc-devel
mailing list