映射GTK2 :: GDK :: PixBuf是否会在Perl上产生内存泄漏?
我需要从同一图像加载多个尺寸,请参阅我的perl gtk2代码:
use utf8;
use strict;
use warnings;
use Gtk2;
use Glib qw/TRUE FALSE/;
sub cb_destroy
{
Gtk2->main_quit;
}
sub Main {
my $title = shift;
Gtk2->init;
my $window = Gtk2::Window->new('toplevel');
$window->set_default_icon_list(
map {
Gtk2::Gdk::Pixbuf->new_from_file_at_scale(
'cat-purr-icon_128.png', $_, $_, TRUE )
} 128, 64, 48, 32, 16
);
$window->signal_connect(destroy => \&cb_destroy);
$window->show_all;
Gtk2->main;
return 0;
}
exit Main('Testing');
该代码按预期工作,但是我想知道map
多次调用的方法
I need to load multiple sizes from same image, see my perl gtk2 code:
use utf8;
use strict;
use warnings;
use Gtk2;
use Glib qw/TRUE FALSE/;
sub cb_destroy
{
Gtk2->main_quit;
}
sub Main {
my $title = shift;
Gtk2->init;
my $window = Gtk2::Window->new('toplevel');
$window->set_default_icon_list(
map {
Gtk2::Gdk::Pixbuf->new_from_file_at_scale(
'cat-purr-icon_128.png', $_, $_, TRUE )
} 128, 64, 48, 32, 16
);
$window->signal_connect(destroy => \&cb_destroy);
$window->show_all;
Gtk2->main;
return 0;
}
exit Main('Testing');
The code works as expected, but I would like to know if map
method of calling multiple times Gtk2::Gdk::Pixbuf->new_from_file_at_scale in Gtk2::Window->set_default_icon_list produces memory leak? If so, what would be an alternative way to deal with my goal: use multiple sizes from the same image.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论