allocate array with new

Andrej Mitrovic andrej.mitrovich at gmail.com
Tue May 15 11:45:28 PDT 2012


On 5/15/12, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> If you're going to use anything, use clear.

He might as well just use this if he wants the GC to take care of things:
arr = null;

clear(arr) is a little bit of a misnomer. If you have another slice
pointing to the same array clear() won't really release memory at all,
it will just make the first slice null. so using "arr = null" is good
enough.

Also good to note is that clear/null assign is very different from
what delete does. delete won't care that you have other slices
pointing to the same array and you'll end up with slices that point to
garbage after a call to delete.


More information about the Digitalmars-d-learn mailing list