[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Gtk2::ImageView memory issue
- From: zentara <zentara1 sbcglobal net>
- To: gtk-perl-list gnome org
- Subject: Re: Gtk2::ImageView memory issue
- Date: Wed, 4 Mar 2009 14:50:47 -0500
On Wed, 04 Mar 2009 20:08:56 +0100
Mario Kemper <mario kemper googlemail com> wrote:
>Hi there,
>
>I've implemented parts of my application with help of the great
>Gtk2::ImageView module.
>In the last days i've noticed some memory leaking and found out that
>Gtk2::ImageView::Tool::Selector is the reason for that. I've attached a
>little demo to demonstrate my problem. Each time you press the Button a
>screenshot will be taken and the ImageView will be updated. In this sub
>the Gtk2::ImageView::Tool::Selector is created each time. While pressing
>the button you can see that used memory will get higher and higher...So
>there is a possible memory leak here.
>
>Of course it is not useful to create the Gtk2::ImageView::Tool::Selector
>each time, but this is just a little test to demonstrate my problem (the
>functionality is in a module in my app).
>
>Does anyone has a clue what to do here? Maybe i am doing something
>totally wrong ...
>sub fct_take_screenshot {
> my $button = shift;
> my $view = shift;
> #!!!!!!uncomment the following two lines to fix the memory leak here!!!!!!
> my $selector = Gtk2::ImageView::Tool::Selector->new($view);
> $view->set_tool($selector);
I don't have Gtk2::ImageView installed, some dependency hassle IIRC.
But, you answered your own question... making a new selector probably is
bad.
You could try putting the following as a global in main:
my $selector = Gtk2::ImageView::Tool::Selector->new( undef );
or possibly before you leave the sub:
$selector->destroy;
undef $selector;
I've also had good luck, with just declaring a global like this,
to reuse it's scalar namespace.
# in main
my $selector; #global scalar space
# in sub
$selector = Gtk2::ImageView::Tool::Selector->new($view);
$view->set_tool($selector);
# at end of sub
$view->set_tool(undef);
$selector->destroy;
Just guessing at hacks from prior experience.
:-)
zentara
--
I'm not really a human, but I play one on earth.
http://www.zentara.net/~zentaran/My_Petition_to_the_Great_Cosmic_Conciousness.html
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]