Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dispose Memory for a Dynamic Array

50 views
Skip to first unread message

Alejandro Moreno Aguirre

unread,
May 4, 2002, 12:40:33 PM5/4/02
to
I have declared a dynamic like:
sizes: Array Of Integer;

and allocated memory for it:
SetLength(sizes,10);

Would I dispose the memory allocated for this array, as dynamic memory that
it is?
I have tryed with Dispose and FreeMem but in both cases it hadn't worked.

Thomas Mueller

unread,
May 4, 2002, 12:53:23 PM5/4/02
to
Hi,

Alejandro Moreno Aguirre wrote:

> I have declared a dynamic like:
> sizes: Array Of Integer;

> and allocated memory for it:
> SetLength(sizes,10);

> Would I dispose the memory allocated for this array, as dynamic
> memory that it is?

What about setlength(sizes, 0) ?

MfG :-)
Thomas

Bruce Roberts

unread,
May 4, 2002, 12:36:09 PM5/4/02
to

"Alejandro Moreno Aguirre" <alex....@arrakis.es> wrote in message

> Would I dispose the memory allocated for this array, as dynamic memory
that
> it is?
> I have tryed with Dispose and FreeMem but in both cases it hadn't worked.

You don't have to release dynamic arrays. Their memory is automatically
released when the array goes out of scope or the record, object, or class
instance owning them is released. You can, if you want, release the memory
earlier by setting their length to zero.

Rudy Velthuis (TeamB)

unread,
May 4, 2002, 12:57:24 PM5/4/02
to
In article <3cd40d8a_1@dnews>, Alejandro Moreno Aguirre says...

> Would I dispose the memory allocated for this array, as dynamic memory that
> it is?
> I have tryed with Dispose and FreeMem but in both cases it hadn't worked.

You don't have to. If you want to get rid of it, set each variable
pointing to it to nil, but normally Delphi will insert code that handles
this automatically.
--
Rudy Velthuis (TeamB)

"If we knew what it was we were doing, it would not be called research,
would it?" -- Albert Einstein

0 new messages