Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0002582 [JEDI VCL] 00 JVCL Components major always 2005-01-31 11:54 2005-05-14 14:08
Reporter Simes View Status public  
Assigned To obones
Priority normal Resolution fixed  
Status resolved   Product Version 3.00 BETA 2
Summary 0002582: TJvTreeView is very slow, and gets slower with use. Memory leak?
Description Run 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 Information unit 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.

Tags No tags attached.
Attached Files zip file icon mantis 2582.zip [^] (2,008 bytes) 2005-02-03 07:56

- Relationships

-  Notes
(0006364)
obones (administrator)
2005-02-03 07:54

I can see that as well.
Unfortunately, I have no time to investigate this any further.
Please use attached project for testing.
(0006963)
obones (administrator)
2005-04-12 07:55

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.
(0007164)
obones (administrator)
2005-05-14 14:08

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


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker