> Date: Sun, 9 Feb 2014 13:08:16 +0100
> From: freepas...@ypa-software.de
> To: fpc-pascal@lists.freepascal.org
> Subject: Re: [fpc-pascal] High() and Low() for empty dynamic arrays
> 
> Am 09.02.2014 13:05, schrieb Fred van Stappen:
> > if length(MyArray) > 0 then
> >   for x := 0 to high(MyArray) do
> >     MyArray[x].Free;
> > 
> > But, if i use :
> > 
> >  setlength(MyArray, 0) ;
> > 
> > would it do the same job ?
> 
> No. Your array contains only references to the objects. The references
> where deleted, but the objects remain in memory without any destructor call.
> 
> g
> Michael

OK, many thanks Michael.

Hum, i have a dynamic array of threads.

mythread.create has :
FreeOnTerminate := True;  

So, when the thread terminate, it frees the memory too ? (yes/no).
And it explain why i get a crash and error message if i try to do, for dynamic 
arrays of threads :

 > if length(MyArray) > 0 then
 >   for x := 0 to high(MyArray) do
 >     MyArray[x].Free;

Because the threads are already freed (yes/no) ?

If so, how can i know if      MyArray[x] was already freed ?

When i use:
if assigned(MyArray[x]) then MyArray[x].Free; 

It does not work. 

Many thanks.

Fred
                                          
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to