Question: In some inherited legacy code, I've traced a problem with random garbage appearing in output to a non-initialized data structure. It's defined as:

```
MyArray: array of array of ShortString;

```

As we read values from this structure, we're sometimes getting junk that is clearly coming from a Bad Place, and which changes every time we run it.

I thought that this would be the correct way to initialize this array:

```
FillChar (MyArray, SizeOf (MyArray), 0)

```

However, as I started reading various sites, I began to doubt myself. Is that the best/correct way to initialize this array? Is 0 the correct FillValue, or should it maybe be #32?

Answer: 
Since no size is specified this is a dynamic array. Fillchar is not the correct way to initialize those. Since they are managed types they are automatically initialized. If later you want to empty the array you can use `SetLength(MyArray,0)` or just `MyArray := nil`.
Afaik shortstrings are not auto initialized. So, setlength to the right sizes, e.g.

```
setlength(myarray,10,12);

```

then set the length of all strings to 0:

```
for i:=0 to length(myarray)-1 do
  for j:=0 to length(myarray[i])-1
      setlength(myarray[i][j],0);

```