Bonjour ,
J'ai un gros problème de libération de mémoire et je ne vois pas ou est mon erreur ...
J'ai une structure de ce type :
type
TMyObject = class
private
public
constructor Create ;
destructor Destroy ;
end;
TMyList = class(TObjectList)
protected
function Get( Index : Integer ) : TMyObject;
procedure Put( Index : Integer; Item : TMyObject);
public
property Items[ Index : Integer ] : TMyObject read Get write Put; default;
constructor Create;
end;
TAutreObject = class
private
MyList : TMyList;
// blabalbla
public
construtor Create ;
procedure RemoveAll;
...
implementation
{ - TMyObject ---------------------------------------------------------- }
constructor TMyObject .Create
begin
inherited Create;
end;
destructor TMyObject .Destroy
begin
// je supprime bien sur ts ce que j'ai pu creer ici, mais pr l'exemple, ca n'en vaut pas la peine ...
inherited Destroy;
end;
{ - TMyList ---------------------------------------------------------- }
constructor TMyList .Create;
begin
inherited Create(True);// OwnObject est a True, Donc libération des Objects Automatique !
end;
function TMyList .Get( Index : Integer ) : TMyObject;
begin
Result := inherited Get( Index );
end;
procedure TMyList .Put( Index : Integer; Item : TMyObject);
begin
inherited Put( Index, Item );
end;
{ - TAutreObject ---------------------------------------------------------- }
construtor TAutreObject .Create ;
begin
inherited Create;
MyList := TMyList.Create;
// blablabla
end;
procedure TAutreObject .RemoveAll;
var
i : integer;
begin
for i:=0 to MyList.Count-1 do begin
//Supprime un objet spécifié de la liste
// et (si OwnsObjects est à true) libère l'objet. MyList.Rmove(MyList.Items[i]);
end;
MyList.Capacity := MyList.Count;
// Mais il ne supprime rien ! Enfin si , mon vecteur est vide
//mais ma mémoire est toujours autant occupée , prq ?!!end;
Voila ben ma question est simple , Pourquoi ca ne me libère rien coté mémoire ?!
Merci