in reply to Tk::Compound memory leak or poor coding?
Then I just call makeimages() in columnInsert and configure the images using a configure(-image) on the button in question when I need to change it. I figured that three images in memory at once is way better than one at a time if having one at a time leads to a memory leak. Anyway, when doing it this way, there is no leakage, so it seems to me that the problem only occurs after repeated Compound image creations and deletions.sub makeimages { my $w = shift; foreach (qw /uparrow downarrow none/) { $w->{$_}->delete if (defined($w->{$_})); $w->{$_} = $w->Compound; $w->{$_}->Line; $w->{$_}->Text( -text => $w->cget('-text'), ); if ($_ eq 'none') { $w->{$_}->Space(-width => 15); } else { $w->{$_}->Bitmap(-bitmap => $_); } } $w->OnDestroy( sub { foreach (qw /uparrow downarrow none/) { $w->{$_}->delete if (defined($w->{$_})); } } ); }
|
|---|