Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi ShellTreeView Memory Leak (https://www.delphipraxis.net/184993-shelltreeview-memory-leak.html)

Bjoerk 6. Mai 2015 14:46

ShellTreeView Memory Leak
 
Liste der Anhänge anzeigen (Anzahl: 1)
Ich bekomme bei ShellTreeViews ein Memory Leak sobald die Komponente nur auf der Form ist. Hat jemand dieses Leak auch mal gehabt bzw. gefunden an was es lag? Die Fehlermeldung ist leider ziemlich dürftig?

Bjoerk 6. Mai 2015 17:00

AW: ShellTreeView Memory Leak
 
Da ist doch was:

[DCC Warnung] ShellCtrls.pas(209): W1010 Methode 'Destroy' verbirgt virtuelle Methode vom Basistyp 'TCustomTreeView'

Delphi-Quellcode:
procedure TCustomShellTreeView.CreateWnd;
begin
  inherited CreateWnd; // ????????????????
  if (Items.Count > 0) then
    ClearItems;
  if not Assigned(Images) then SetUseShellImages(FUseShellImages);
  { TODO : What is the Items.Count test for here? }
  if (not FLoadingRoot) {and (Items.Count = 0)} then
    CreateRoot;
end;

destructor TCustomShellTreeView.Destroy; // *************************
begin
  ClearItems;
  FRootFolder.Free;
  inherited;
end;
Beim destructor von TCustomShellTreeView stand kein ovveride. Wenn man das einfügt bekommt man nun folgende Fehlermeldung: ShellTreeView (so heißt die Instanz) hat kein übergeordnetes Fenster. ???

Bjoerk 6. Mai 2015 18:44

AW: ShellTreeView Memory Leak
 
Das löst die Exception aus.
Delphi-Quellcode:
procedure TCustomShellTreeView.ClearItems;
var
  I: Integer;
begin
  Items.BeginUpdate; // ****************
  try
    for I := 0 to Items.Count-1 do
    begin
      if Assigned(Folders[i]) then
        Folders[I].Free;
      Items[I].Data := nil;
    end;
    Items.Clear;
  finally
    Items.EndUpdate;
  end;
end;
Ich schreib das jetzt ohne die BeginEndUpdates in den destructor und gut ist. Kein Bock mehr..

Bjoerk 6. Mai 2015 19:17

AW: ShellTreeView Memory Leak
 
Liste der Anhänge anzeigen (Anzahl: 1)
Jetzt muß ich doch noch mal nachfragen. Ich hab das Package entfernt und wollte es neu installieren. Nun will "er" das aber nicht. :oops:

BadenPower 6. Mai 2015 19:49

AW: ShellTreeView Memory Leak
 
Zitat:

Zitat von Bjoerk (Beitrag 1300506)
Jetzt muß ich doch noch mal nachfragen. Ich hab das Package entfernt und wollte es neu installieren. Nun will "er" das aber nicht. :oops:

Entfernt, oder nur das Häkchen entfernt?

Das Dialogfenster mit den Packages nach dem Entfernen auch geschlossen und dann wieder geöffnet und dann erst das gleichnamige Package installiert?

Im Notfall IDE neu gestartet?


Ja ich weiss, sind banale Fragen, aber über solche lapidaren Sachen stolpert man manchmal, wenn man schon zu lange über eine Sache grübelt.

Sir Rufo 6. Mai 2015 20:09

AW: ShellTreeView Memory Leak
 
Zitat:

Zitat von Bjoerk (Beitrag 1300506)
Jetzt muß ich doch noch mal nachfragen. Ich hab das Package entfernt und wollte es neu installieren. Nun will "er" das aber nicht. :oops:

Meinst du schaffst es statt dieser PDF im Anhang einfach in dem Dialog STRG-C zu drücken und dann hier im Editor STRG-V?

Das spart Speicherplatz und Bandbreite und schneller lesbar ist es auch noch ... und sogar suchbar, kurz gesagt nur Vorteile.
Das Verfahren nennt sich im Übrigen CopyPaste ;)

Luckie 6. Mai 2015 20:31

AW: ShellTreeView Memory Leak
 
Ach du meine Güte. Screenshots als PDF. Da sind wir wohl haarscharf an einem Word Dokument vorbei geschlittert. :shock:

Klaus01 6. Mai 2015 20:35

AW: ShellTreeView Memory Leak
 
Hallo,

vielleicht hilft der Thread hier weiter.

Zitat:

Hi, there is a missing "override" and a wrong ClearItems in TCustomShellTreeView.Destroy.
Hope this helps

Jürgen

----------------------
{ TCustomShellTreeView }
....
Delphi-Quellcode:
  TCustomShellTreeView = class(TCustomTreeView, IShellCommandVerb)
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override; //$$jp shellctrl.pas 26.08.2007: missing "override"
    procedure Refresh(Node: TTreeNode);
....

Delphi-Quellcode:
destructor TCustomShellTreeView.Destroy;
begin
  //$$jp: ClearItems;
  //$$jp: raises EInvalidOperation and access-violations (shellctrl.pas 26.08.2007)
  FRootFolder.Free;
  inherited;
end;

Grüße
Klaus

Bjoerk 6. Mai 2015 20:39

AW: ShellTreeView Memory Leak
 
Ob ich diesem Leben mal noch von Luckie eine gescheite Antwort bekomm? :gruebel: Ich fürchte nein..

BadenPower, ja, "ordentlich" entfernt (nicht nur das Häkchen weggemacht). Und Ide neu gestartet. Auch Windows.

Sir Rufo, falls du damit was anfangen kannst, bitte sehr:
Code:
[2166EA47]{delphicoreide100.bpl} PakList.TPackageList.AddPackage (Line 441, "PakList.pas" + 7) + $2F
[2167AA36]{delphicoreide100.bpl} BasePasProjOpts.TProjOptsManager.InstallPackage (Line 2271, "BasePasProjOpts.pas" + 8) + $5
[2167E777]{delphicoreide100.bpl} BasePasProjOpts.TProjectOptions.InstallPackage (Line 3287, "BasePasProjOpts.pas" + 0) + $3
[216A36E1]{delphicoreide100.bpl} PasMgr.TPascalPackageCodeUpdater.InstallPackage (Line 11185, "PasMgr.pas" + 17) + $19
[21669A25]{delphicoreide100.bpl} PkgContainers.TStdPackageProjectContainer.CommandHandler (Line 151, "PkgContainers.pas" + 5) + $5
[209F21D9]{coreide100.bpl} Containers.TStdContainer.CommandHandler (Line 3069, "Containers.pas" + 1) + $17
[201305E7]{vcl100.bpl } Menus.TMenuItem.Click (Line 2283, "Menus.pas" + 14) + $8
[20131B0F]{vcl100.bpl } Menus.TMenu.DispatchCommand (Line 3008, "Menus.pas" + 5) + $2
[20132C6E]{vcl100.bpl } Menus.TPopupList.WndProc (Line 3798, "Menus.pas" + 4) + $E
[20132BBD]{vcl100.bpl } Menus.TPopupList.MainWndProc (Line 3779, "Menus.pas" + 2) + $5
[20040E4C]{rtl100.bpl } Classes.StdWndProc (Line 11583, "common\Classes.pas" + 8) + $0
[201625F0]{vcl100.bpl } Forms.TApplication.ProcessMessage (Line 8105, "Forms.pas" + 23) + $1
[2016262A]{vcl100.bpl } Forms.TApplication.HandleMessage (Line 8124, "Forms.pas" + 1) + $4
[2016291F]{vcl100.bpl } Forms.TApplication.Run (Line 8223, "Forms.pas" + 20) + $3
[0042297A]{bds.exe    } bds.bds (Line 195, "" + 7) + $7

Bjoerk 6. Mai 2015 20:41

AW: ShellTreeView Memory Leak
 
Klaus, genau so hab ich es gemacht :thumb:


Alle Zeitangaben in WEZ +1. Es ist jetzt 06:21 Uhr.
Seite 1 von 2  1 2      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz