On 28/03/14 02:50, Xiangrong Fang wrote:
var
a2: array of array of Integer;
i, j: Integer;
begin
SetLength(a2, 3);
for i := 0 to 2 do begin
SetLength(a[i], 3);
for j := 0 to 2 do a[i][j] := 1;
end;
a2 := nil; <-- will this free all memory of a[0]...a[2]?
end;
Yes.
If I have this:
var
a2: array of array of Integer;
i, j: Integer;
begin
SetLength(a2, 3);
for i := 0 to 2 do begin
SetLength(a[i], 3);
for j := 0 to 2 do a[i][j] := 1;
end;
a2 := nil; <-- will this free all memory of a[0]...a[2]?
end;
Thanks!
Xiangrong
___
On 05/04/2010, cobines wrote:
> >>
> > I'm not sure that is correct. Once you free Test, Pest still points to
> > the same non existing object and you can use assigned to check it,
>
>
> Pest would be a dangling pointer and should not be accessed.
Correct, and that was what I was trying to get
2010/4/5 Werner Van Belle :
>> Pest was just a reference pointer to the first instance, so no need to
>> free it. But setting it to nil after Test was freed is a good habit.
>>
> I'm not sure that is correct. Once you free Test, Pest still points to
> the same non existing object and you can use as
Graeme Geldenhuys wrote:
>> Test:=nil;
>>
>
> This causes a memory leak - you did not actually free the class
> instance. You need to call: Test.Free;
>
Of course I didn't call free; I was hoping that the reference counter
would solve that little problem. If I need to free stuff myself,
04.04.2010 22:53, Zaher Dirkey wrote:
But he must use variable of interface to use TInterfacedObject not
variable of TObject to take this advantage (if i am not wrong).
You are not wrong.
Best regards,
Paul Ishenin.
___
fpc-pascal maillist - fpc-pas
On Sat, Apr 3, 2010 at 10:59 PM, Graeme Geldenhuys
wrote:
> On 3 April 2010 21:01, Werner Van Belle wrote:
>
If you wanted real reference counted objects that gets freed
> automatically when nothing is referencing it, then create a descendant
> of TInterfacedObject.
>
>
But he must use variable
On 3 April 2010 21:01, Werner Van Belle wrote:
>
> Type
> TReferenceCount = Class
That is the same as...
TReferenceCount = class(TObject)
> var
> Test : TReferenceCount;
> Pest : TReferenceCount;
> begin
> Test:=TReferenceCount.Create();
...snip...
> Test:=nil;
This caus
Hello Dear Freepascal users,
I'm a newbee to object pascal. I did however program in turbo pascal.
The past couple of days I learned that there exist a variety of
classes/object systems in freepascal. Now, I already figured out that
the generic class generators are that what we are looking for, wh