Einzelnen Beitrag anzeigen

delphinub23

Registriert seit: 27. Okt 2010
Ort: Chemnitz
110 Beiträge
 
Delphi XE3 Professional
 
#8

AW: Hilfestellung zu meinem Speicherleck

  Alt 9. Mai 2011, 18:25
Das ist meine Routine, die die TStringlists (Global definiert und einmal Form.Create angelegt -- Form.Destroy zerstört diese auch wieder) benötigt.

Delphi-Quellcode:
procedure TFmMainModule.InitializeListview(const Processes: TStrings; const PIDs: TStrings; const Affinities: TStrings);
var
  Index: integer;
  i: Integer;
begin
  try
    lvProcessList.Items.BeginUpdate;
    try
      lvProcessList.Clear;
      ImageList.Clear;
      // reset TImageList index value
      Index := 0;

      // get processes
      ProcessInformation[0] := Processes;
      // pids
      ProcessInformation[1] := PIDs;
      // affinities
      ProcessInformation[2] := Affinities;
      // icons
      for i := 0 to Pred(ProcessInformation[0].Count) do
      begin
        SetExeIconToImageList(Imagelist, Index, StrToInt(PIDs.Strings[i]));
        Inc(Index);
      end;
    finally
      lvProcessList.Items.Count := ProcessInformation[0].Count;
      lvProcessList.AlphaSort;
      lvProcessList.Items.EndUpdate;
    end;
  except
    MessageDlg('Could not initialize application!', mtError, [mbOk], 0);
    Application.Terminate;
  end;
end;

@ DeddyH:
Zitat:
Zitat:
Delphi-Quellcode:
   finally
     sl := nil;
     sl.Free;
   end;
Wenn ich nur .Free rufe, dann bekomme ich eine Exception. Darum diese komische Variante

Geändert von delphinub23 ( 9. Mai 2011 um 18:29 Uhr)
  Mit Zitat antworten Zitat