Einzelnen Beitrag anzeigen

xaromz

Registriert seit: 18. Mär 2005
1.682 Beiträge
 
Delphi 2006 Enterprise
 
#1

Re: Memory Leak bei INDY 10 in der SMTP Komponente?

  Alt 29. Aug 2006, 18:16
Hallo,

folgende Änderungen in der Datei idStack.pas sind notwendig, sonst kann es knallen (was ja der Grund für den Leak ist):
Nach Implementation:
Delphi-Quellcode:
var
  GInstanceCount: Integer = 0;
  GStackCriticalSection: TIdCriticalSection;
wird zu
Delphi-Quellcode:
var
  GInstanceCount: Integer = 0;
  GStackCriticalSection: TIdCriticalSection;
  GDestroying: Boolean; // Neue Variable
Die Methode TIdStack.DecUsage muss erweitert werden:
Delphi-Quellcode:
...
  finally GStackCriticalSection.Release; end;

  // Auf Destroying reagieren
  if (GInstanceCount = 0) and GDestroying then
    Sys.FreeAndNil(GStackCriticalSection);
end;
und am Ende:
Delphi-Quellcode:
finalization
  GDestroying := True;
  if GInstanceCount = 0 then
    Sys.FreeAndNil(GStackCriticalSection);
//Edit: Meine Lösung gilt für Version Version 10, jbg's für Version 9.
Gruß
xaromz
I am a leaf on the wind - watch how I soar
  Mit Zitat antworten Zitat