in reply to ItemStyle causing high memory consumption

Hi, this interested me a bit, so I tried to setup a simple example of the way to get the ItemStyle from a packaged Tree. This seems to work, but I have no idea how your memory gain would be affected, or if it is the problem you are trying to describe. Anyways, can you reformulate your question in terms of this simple example? Is the fact that all the Style objects are different the cause of the memory gain problem you experience? Are you looking for a setup where only 2 ItemStyle objects are created instead of 4?

Anyways, its a start for other monks who may know more about OO.

#!/usr/bin/perl use warnings; use strict; use Tk; package ZTree; use base qw(Tk::Derived Tk::Tree); require Tk::ItemStyle; Tk::Widget->Construct('ZTree'); sub ClassInit { my ($class, $mw) = @_; #set the $mw as parent $class->SUPER::ClassInit($mw); } # end ClassInit sub Populate { my ( $self, $args ) = @_; print "@_\n"; $self->SUPER::Populate($args); $self->{'tree'} = $self->Tree(); $self->Advertise( Tree => $self->{'tree'} ); my $tree = $self->{'tree'}; $self->{'red_style'} = $tree->ItemStyle('text', -refwindow => $tree +, -bg => 'red'); $self->{'green_style'} = $tree->ItemStyle('text', -refwindow => $tr +ee, -bg => 'green'); $tree->autosetmode; print "2\n"; } 1; package main; use Tk; my $mw = MainWindow->new; $mw->geometry("400x400"); my $tree = $mw->ZTree( -bg => 'white') ; $tree->add(1, -text => 'abcd', -itemtype => 'text', -style => $tree +->{'red_style'}); $tree->add(2, -text => '1234', -itemtype => 'text', -style => $tree +->{'green_style'}); $tree->pack(-fill=>'both',-expand => 1); my $tree1 = $mw->ZTree( -bg => 'black') ; $tree1->add(1, -text => 'abcd', -itemtype => 'text', -style => $tre +e1->{'red_style'}); $tree1->add(2, -text => '1234', -itemtype => 'text', -style => $tre +e1->{'green_style'}); $tree1->pack(-fill=>'both',-expand => 1); my $button1 = $mw->Button( -text=>'Exit', -command=> sub{exit} )->pack +(); my $button2 = $mw->Button( -text=>'Get Styles', -command=> sub{ my $style1 = $tree->entrycget(1, '-style'); print "$style1\n"; my $style2 = $tree->entrycget(2, '-style'); print "$style2\n"; my $style3 = $tree1->entrycget(1, '-style'); print "$style3\n"; my $style4 = $tree1->entrycget(2, '-style'); print "$style4\n"; } )->pack(); Tk::MainLoop;

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh