[Lazarus] testing virtual TListView in gtk2
Andrew Haines
AndrewD207 at aol.com
Thu Dec 3 17:14:41 CET 2009
Seth Grover wrote:
> Basically I created a form and dropped a TListView onto it and set the
> OwnerData property to True, then defined an OnData event like:
>
> procedure TForm1.ListView1Data(Sender: TObject; Item: TListItem);
> begin
> Item.Caption := 'Item ' + IntToStr(Item.Index + 1);
> end;
>
> Then in the FormCreate I set the Items.Count property to some value:
>
> procedure TForm1.FormCreate(Sender: TObject);
> begin
> ListView1.Items.Count := 10;
> end;
>
> I ran the program and sure enough, the list showed up with my items
> with the correct caption. Great!
>
> However, for the purposes of testing, I then increased the count to
> 1000000, since a major purpose of a virtual list view is so you don't
> have to eat up all your memory storing the items.
>
> To my dismay, when I ran the program, it ran correctly, but the memory
> usage of my program was huge compared to when I only had 10 items.
Okay In r22945 I have implemented a custom treemodel for the gtk2
listview. This should fix your memory problem.
> I put some writeln's in the OnData method and also discovered that
> that the OnData routine was called, on startup of my program, for each
> of my million items.
>
This still happens because for columns to be autosized it is not allowed
to set the gtktree(list)view to have fixed height rows.
If the new treemodel is not working well you can disable it by compiling
the lcl with -dUseOrigTreeModel
Regards,
Andrew
More information about the Lazarus
mailing list