I'm pretty certain that dynamic arrays get disposed when they go out of scope - they're handled in the same way as strings, and you don't see many people worrying about deallocating strings.

Dynamic arrays are ref-counted, so it seems very likely that they get squished at the end of scope, and very unlikely that they'll be garbage collected at a non-deterministic time.

Of course, there are a couple of ways (maybe three) to manually kill the memory if you're feeling paranoid: set the array var to nil, pass it to the Finalize procedure, or SetLength to 0 (which I think does a deallocation, not that it matters too much). I've got into the habit of manually setting all my vars to nil/0, but that's just extra-safety for a larger project that I have on the backburner. It should be safe to leave 'em alone.

The only thing to remember, and the thing that may have bitten you Crisp_N_Dry: clearing up the memory for the dynamic array won't clear anything dynamic that's stored inside the array's elements! (e.g. GetMem'd pointers or created classes). I think.. You'd want to clear the array elements by looping over them in the usual fashion - for i := Low(whatever) to High(Whatever) do FreeMem(Whatever[i]); // or equivalent squishing-stored-dynamic-mem.

Here's a relevant link: http://www.info.umfcluj.ro/resurse/C...html#Heading22

Anecdotal evidence, anyway - Charlie Calvert doesn't worry about deallocating the dynamic arrays, and I trust his judgement a lot. Also, two quotes from the help:

Dynamic-array variables are implicitly pointers and are managed by the same reference-counting technique used for long strings
...and:

This memory is allocated on the heap, but its management is entirely automatic and requires no user code
If dynamic arrays use the same mechanism as long strings, and long strings are managed automatically, then [insert_conclusion_here].