![]() |
Memory Leak bei INDY 10 in der SMTP Komponente?
Liste der Anhänge anzeigen (Anzahl: 1)
Moin,
man nehme eine leere Form. Die erste Anweisung beim Start sollte der Aufruf des MemoryManagers sein:
Delphi-Quellcode:
Auf die Mainform ziehe man aus IndyClients die SMTP Komponente.
program test;
uses Forms, main in 'main.pas' {frmmain}; {$R *.res} begin ReportMemoryLeaksOnShutdown := True; Application.Initialize; Application.CreateForm(Tfrmmain, frmmain); Application.Run; end. Compilieren, starten, beenden ..... => Meldung siehe Anhang Gruss EL |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Hallo,
das ist ein bekanntes Problem. in den INDYs wird irgendwo eine TIdCriticalScetion angelegt und nicht mehr freigegeben. Das ist sogar im Quellcode so vermerkt. Da steht sinngemäß: "Da wir nicht wissen, ob das Objekt später noch verwendet wird, lassen wir es leben und von Windows wegräumen, wenn das Programm beendet wird." Gruß xaromz |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Zitat:
Gruss Jörg |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Hallo,
Zitat:
Gruß xaromz |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Zitat:
Gruss EL |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Hallo,
Zitat:
Gruß xaromz |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
@emsländer
womit hast du diese leak meldung hinbekommen? sowas brauch ich auch :) |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Zitat:
Delphi-Quellcode:
Beispiel:
ReportMemoryLeaksOnShutdown := True;
Delphi-Quellcode:
Gruss
program test;
uses Forms, main in 'main.pas' {frmmain}; {$R *.res} begin ReportMemoryLeaksOnShutdown := True; Application.Initialize; Application.CreateForm(Tfrmmain, frmmain); Application.Run; end. EL |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Hallo,
Zitat:
Gruß xaromz |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Zitat:
Gruss EL |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Hallo,
Zitat:
Gruß xaromz |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Zitat:
Gruss EL |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Zitat:
|
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
oder MemCheck, welches dir bei eingeschalteten Debuginfos sogar die stelle Anzeigt, bei der das Leak entstanden ist, mitsamt dem kompletten Aufruf-Stack.
mfG Markus |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Zitat:
|
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Hallo,
Zitat:
Gruß xaromz |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Zitat:
Gruss EL |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Datei IdComponent.pas
Delphi-Quellcode:
Das die beim schreiben des Kommentars nicht gleich darauf gekommen sind :shock: Aber der Indy-Code ist sowieso etwas undurchsichtig (von der Formatierung mal abgesehen)
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. |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Ach ja und dann:
dcc32.exe -U..\..\lib -R..\..\lib -M -$D- IdComponent.pas move IdComponent.dcu ..\..\lib dcc32.exe -U..\..\lib -R..\..\lib -M -$D+ IdComponent.pas move IdComponent.dcu ..\..\lib\debug Das Indy-Package muss, wenn man es nutzt, auch neu gebaut werden. |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Zitat:
Gruss EL |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
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:
wird zu
var
GInstanceCount: Integer = 0; GStackCriticalSection: TIdCriticalSection;
Delphi-Quellcode:
Die Methode TIdStack.DecUsage muss erweitert werden:
var
GInstanceCount: Integer = 0; GStackCriticalSection: TIdCriticalSection; GDestroying: Boolean; // Neue Variable
Delphi-Quellcode:
und am Ende:
...
finally GStackCriticalSection.Release; end; // Auf Destroying reagieren if (GInstanceCount = 0) and GDestroying then Sys.FreeAndNil(GStackCriticalSection); end;
Delphi-Quellcode:
//Edit: Meine Lösung gilt für Version Version 10, jbg's für Version 9.
finalization
GDestroying := True; if GInstanceCount = 0 then Sys.FreeAndNil(GStackCriticalSection); Gruß xaromz |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Hi,
Wenn ich das versuche zu compilieren (D2006/Indy10) dann bekomme ich die Fehlermeldung: [Pascal Fataler Fehler] IndySystem.dpk(29): E2202 Package 'Borland.Delphi' wird benötigt, konnte aber nicht gefunden werden. Wo soll das denn stecken? Gruss EL |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Hallo,
Zitat:
Lösung hab' ich leider keine. Ich habe einfach den Suchpfad meines Projekts angepasst und kompiliere die Units in meine Anwendung mit rein. Gruß xaromz |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Zitat:
|
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Zitat:
Wie? Gruss EL |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Zitat:
Delphi-Quellcode:
behalten, oder ersetzen?
{$IFDEF IDFREEONFINAL}
Sys.FreeAndNil(GStackCriticalSection); {$ENDIF} Gruss EL |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Hallo,
Zitat:
Delphi-Quellcode:
Gruß
initialization
GDestroying := False; GStackClass := {$IFDEF LINUX} TIdStackLinux; {$ENDIF} {$IFDEF MSWINDOWS} TIdStackWindows; {$ENDIF} {$IFDEF DOTNET} TIdStackDotNet; {$ENDIF} GStackCriticalSection := TIdCriticalSection.Create; finalization GDestroying := True; if GInstanceCount = 0 then Sys.FreeAndNil(GStackCriticalSection); end. xaromz |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Zitat:
und wie nun compilieren? Gruss EL |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
Zitat:
Wie muss ich nun verfahren, um die Indylib neu zu bauen? Gruss EL |
Re: Memory Leak bei INDY 10 in der SMTP Komponente?
- ich pushe dieses Thema noch einmal, weil Borland einer Anfrage nicht nachkommt und auf den kostenpflichtigen Support verweist. -
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:21 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz