Ver Mensaje Individual
  #1  
Antiguo 05-05-2011
sirmenon sirmenon is offline
Registrado
 
Registrado: abr 2010
Posts: 9
Reputación: 0
sirmenon Va por buen camino
memory leak em classe

Olá amigos,
Estou com um problema de memory laeak e não estou conseguindo identifica-lo.
Segue o meu código:

Eu tenho a seguinte classe:
Código Delphi [-]
type 
  TFormParam = class 
  private 
    FCampos: string; 
    procedure SetCampos(const Value: string); 
  public 
    VinculaCampos : TStringList; 
    property Campos: string read FCampos write SetCampos; 
  Constructor Create; 
    destructor Destroy; 
  end; 
  
   ... 
  
constructor TFormParam.Create; 
begin 
  VinculaCampos := TStringList.Create;   
end; 
  
destructor TFormParam.Destroy; 
begin 
  VinculaCampos.Free; 
  inherited; 
end; 
  
procedure TFormParam.SetCampos(const Value: string); 
begin 
  FCampos := Value; 
  VinculaCampos.CommaText := Value; 
end;

Estou utilizando ela para passar informações de um Form para o outro, como no exemplo:

No Form1 eu chamo assim:
Código Delphi [-]
  
   objParam := TFormParam.Create; 
   try 
     objParam.Campos := 'Neil=45, Brian=63, Jim=22'; 
   if Form2 = nil then 
       Form2 := TForm2.Create(Self,objParam); 
     Form2.ShowModal; 
   finally 
     objParam.Free; 
   end;

No Form2 eu utilizo assim:
Código Delphi [-]
constructor TForm2.Create(Owner: TComponent; FrmParametro: TFormParam); 
var 
  i : Integer; 
begin 
  inherited Create(Owner); 
  for I := 0 to FrmParametro.VinculaCampos.Count - 1 do 
  begin 
    lstBox1.Items.Add(FrmParametro.VinculaCampos.Names[i]) ; 
    lstBox2.Items.Add(FrmParametro.VinculaCampos.ValueFromIndex[i]); 
  end; 
end;


Alguém saberia me dizer aonde esta o memory leak?

Última edición por ecfisa fecha: 05-05-2011 a las 20:58:59. Razón: Etiquetas [DELPHI] [/DELPHI]
Responder Con Cita