1
我不明白下面的對象在哪裏以及如何清除它們?如何清除stringlist中的指針?
例如:
public
Alist: TStringlist;
..
procedure TForm1.FormCreate(Sender: TObject);
begin
Alist:=Tstringlist.Create;
end;
procedure TForm1. addinstringlist;
var
i: integer;
begin
for i:=0 to 100000 do
begin
Alist.add(inttostr(i), pointer(i));
end;
end;
procedure TForm1.clearlist;
begin
Alist.clear;
// inttostr(i) are cleared, right?
// Where are pointer(i)? Are they also cleared ?
// if they are not cleared, how to clear ?
end;
procedure TForm1. repeat; //newly added
var
i: integer;
begin
For i:=0 to 10000 do
begin
addinstringlist;
clearlist;
end;
end; // No problem?
我用Delphi 7在Delphi 7.0的幫助文件,它說:
AddObject method (TStringList)
Description
Call AddObject to add a string and its associated object to the list.
AddObject returns the index of the new string and object.
Note:
The TStringList object does not own the objects you add this way.
Objects added to the TStringList object still exist
even if the TStringList instance is destroyed.
They must be explicitly destroyed by the application.
在我的程序Alist.add(inttostr(I)指針(我)),我沒有創建任何對象。那裏有沒有對象? 如何清除inttostr(i)和指針(i)。
預先感謝您
非常感謝。我添加了重複過程。請參見。沒問題?我應該如何測試ReportMemoryLeaksOnShutDown:= True;? – Warren 2013-02-26 10:51:12
@Serg謝謝大家 – Warren 2013-02-26 11:24:04