Thema: Delphi IdTCPServer + MemoryLeak

Einzelnen Beitrag anzeigen

azury

Registriert seit: 18. Dez 2008
8 Beiträge
 
#5

Re: IdTCPServer + MemoryLeak

  Alt 17. Feb 2010, 18:51
//Edit

Okay den Integer hab ich geschafft wegzubekommen aber es ist nur einmal TIdCriticalSection drin
mal gucken ob ich den auch noch raus bekomme....
Okay nun sind beide raus.

Einmal im IdThread
Delphi-Quellcode:
  // This call hangs if not all threads have been properly destroyed.
  // But without this, bad threads can often have worse results. Catch 22.
  TIdThread.WaitAllThreadsTerminated;
  FreeAndNil(GThreadCount);
Das war ausgeklammert, wie dort beschrieben.

Und einmal im IdComponent:
Delphi-Quellcode:
destructor TIdComponent.Destroy;
begin
  inherited;
  // After inherited - do at last possible moment
  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
    GStackCriticalSection.Release;
    FreeAndNil(GStackCriticalSection);
  end;
Da hab ich einfach das FreeAndNil(GStackCriticalSection); angefügt.
Keine Ahnung ob das okay ist was ich da mache, aber es entstehen keine Memleaks mehr.
Wenn einer gute gründe hat warum man das nicht machen sollte, immer her damit.
  Mit Zitat antworten Zitat