Einzelnen Beitrag anzeigen

jbg

Registriert seit: 12. Jun 2002
3.483 Beiträge
 
Delphi 10.1 Berlin Professional
 
#8

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

  Alt 29. Aug 2006, 17:32
Datei IdComponent.pas
Delphi-Quellcode:
destructor TIdComponent.Destroy;
begin
  inherited Destroy;
  // After inherited - do at last possible moment
+ if Assigned(GStackCriticalSection) then
    GStackCriticalSection.Acquire;
  try
    Dec(GInstanceCount);
    if GInstanceCount = 0 then begin
      // This CS will guarantee that during the FreeAndNil nobody will try to use
      // or construct GStack
      FreeAndNil(GStack);
    end;
  finally
+ if Assigned(GStackCriticalSection) then
      GStackCriticalSection.Release;
  end;
end;

...

initialization
  GStackCriticalSection := TCriticalSection.Create;
finalization
- // Dont Free. If shutdown is from another Init section, it can cause GPF when stack
- // tries to access it. App will kill it off anyways, so just let it leak
- // FreeAndNil(GStackCriticalSection);
+ FreeAndNil(GStackCriticalSection);
end.
Das die beim schreiben des Kommentars nicht gleich darauf gekommen sind Aber der Indy-Code ist sowieso etwas undurchsichtig (von der Formatierung mal abgesehen)
  Mit Zitat antworten Zitat