View Issue Details

IDProjectCategoryView StatusLast Update
0002582JEDI VCL00 JVCL Componentspublic2005-05-14 14:08
ReporterSimesAssigned Toobones 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.00 BETA 2 
Target VersionFixed in Version3.10 
Summary0002582: TJvTreeView is very slow, and gets slower with use. Memory leak?
DescriptionRun the code below. This shows the time it takes to load a standard TTreeView compared to a TJvTreeView. On my machine, the standard tree view loads the data in about 0.25 seconds each time it is tested. The TJvTreeView takes 30+ seconds the first time it is loaded, then 100 seconds the second time, 170 seconds the third time, 240 seconds the fourth time. Anybody spot a pattern?

In addition, the memory use goes up and up.

Tested in D7 Enterprise on Win2K.
Additional Informationunit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, JvExComCtrls, JvComCtrls, StdCtrls, ExtCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    TreeView1: TTreeView;
    Panel1: TPanel;
    Button1: TButton;
    Button2: TButton;
    JvTreeView1: TJvTreeView;
    Label1: TLabel;
    procedure FormResize(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    procedure Fill(const tv: TTreeView);
  public
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormResize(Sender: TObject);
begin
  TreeView1.Width := ClientWidth div 2;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Fill(TreeView1);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Fill(JvTreeView1);
end;

procedure TForm1.Fill(const tv: TTreeView);
var
  i, j: integer;
  node: TTreeNode;
  s, e: TDateTime;
begin
  Label1.Caption := '';
  with tv.Items do begin
    Clear;
    s := Now;
    BeginUpdate;
    try
      for i := 1 to 100 do begin
        node := AddChild(nil, IntToStr(i));
        for j := 1 to 2 * i do
          AddChild(node, IntToStr(i));
      end;
    finally
      EndUpdate;
    end;
    e := Now;
    Label1.Caption := FloatToStr((e - s) * 24 * 60 * 60) + ' seconds';
  end;
end;

end.

TagsNo tags attached.

Activities

obones

2005-02-03 07:54

administrator   ~0006364

I can see that as well.
Unfortunately, I have no time to investigate this any further.
Please use attached project for testing.

2005-02-03 07:56

 

mantis 2582.zip (2,008 bytes)

obones

2005-04-12 07:55

administrator   ~0006963

Ok, I tracked that one down, in JvComCtrls;pas:
I comes from the fact that CreateEnh in TJvTreeNode creates a TPopupMenu for every single node and makes the owner to be the TreeView, thus trigerring a call to Notification for each creation.
Further, the memory usage comes from the fact that the menus are not freed untilt the end of the application.
The thing is that I see no reason to create a popup menu per node as the property is not accessible at design time anyway.

So to fix this, I propose this:

1. Comment out Result.FPopupMenu := TPopupMenu.Create(AOwner.Owner);
at line 2207

2. At line 2759, add the following:
              if Assigned(TJvTreeNode(Selected).PopupMenu) then
just before the TJvTreeNode(Selected).PopupMenu.Popup call

That solved the problem for me, and I can't see any side effect as of yet.
Please let me know how it goes.

obones

2005-05-14 14:08

administrator   ~0007164

This is now in CVS.

Issue History

Date Modified Username Field Change
2005-01-31 11:54 Simes New Issue
2005-02-03 07:54 obones Note Added: 0006364
2005-02-03 07:54 obones Status new => acknowledged
2005-02-03 07:56 obones File Added: mantis 2582.zip
2005-04-12 07:55 obones Note Added: 0006963
2005-04-12 07:55 obones Assigned To => obones
2005-04-12 07:55 obones Status acknowledged => feedback
2005-05-14 14:08 obones Status feedback => resolved
2005-05-14 14:08 obones Resolution open => fixed
2005-05-14 14:08 obones Note Added: 0007164