gtk_widget_queue_draw中,Windows 7下的内存泄漏 [英] Memory leak in GTK under Windows 7 in gtk_widget_queue_draw

查看:352
本文介绍了gtk_widget_queue_draw中,Windows 7下的内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下GTK程式:

  #include< gtk / gtk.h> 
GtkVBox * vbox;
GtkWindow * win;
gboolean Timer(gpointer user_data)
{
gtk_widget_queue_draw(GTK_WIDGET(vbox));
返回1;

int main(int argc,char ** argv)
{
gtk_init(& argc,& argv);
win =(GtkWindow *)gtk_window_new(GTK_WINDOW_TOPLEVEL);
vbox =(GtkVBox *)gtk_vbox_new(TRUE,1);
gtk_container_add(GTK_CONTAINER(win),GTK_WIDGET(vbox));
g_timeout_add(200,Timer,0);
gtk_widget_show_all(GTK_WIDGET(win));
gtk_main();
返回0;
}

使用gcc 4.5.2编译时,在Windows 7 64位下泄漏任务管理器显示。在Windows XP 32位下编译时,它不会泄漏。该计划什么都不做。它创建一个窗口,放置一个盒子,然后从每个200ms的计时器调用gtk_widget_queue_draw。



这是一个用于编译和链接测试的批处理文件。变量GTK被设置为包含GTK二进制分布的目录。例如。 2.24.10在这种情况下。

  set GTK = c:/ temp / GTK 
gcc -c -mms- bitfields -I%gtk%/ lib / gtk-2.0 / include -I%gtk%/ lib / gdk-2.0 / include -I%gtk%/ lib / glib-2.0 / include -I%gtk%/ include -I% gtk%/ include / atk-1.0 -I%gtk%/ include / gdk-pixbuf-2.0 -I%gtk%/ include / cairo -I%gtk%/ include / pango-1.0 -I%gtk%/ include / gio -win32-2.0 -I%gtk%/ include / glib-2.0 -I%gtk%/ include / gtk-2.0 test.c
gcc test.o --mwindows -Wl,-luuid -L%gtk% / lib -lgtk-win32-2.0 -lgdk-win32-2.0 -lgobject-2.0 -lglib-2.0 -o test.exe

有什么想法?什么是GTK,gcc,MinGW?一些编译器/链接器选项错过了?

解决方案

这是GTK bug 685959 。大部分漏洞都是在GTK 2.24.14中修复的。

错误707760 跟踪软件包(二进制文件,软件包)更新。


The following GTK program:

#include <gtk/gtk.h>
GtkVBox *vbox;
GtkWindow *win;
gboolean Timer (gpointer user_data)
{
   gtk_widget_queue_draw (GTK_WIDGET (vbox));
   return 1;
}
int main(int argc, char **argv)
{
   gtk_init(&argc, &argv);
   win = (GtkWindow*)gtk_window_new(GTK_WINDOW_TOPLEVEL);
   vbox = (GtkVBox*)gtk_vbox_new(TRUE, 1);
   gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(vbox));
   g_timeout_add (200, Timer, 0);
   gtk_widget_show_all(GTK_WIDGET(win));
   gtk_main();
   return 0;
}

Leaks under Windows 7 64-bit when compiled using gcc 4.5.2 as the task manager shows. It does not leak when compiled under Windows XP 32-bit. The program does nothing. It creates a window, put there are box and then calls to gtk_widget_queue_draw from a timer each 200ms.

Here is a batch file to compile and link the test. The variable GTK is set to directory containing the binary distribution of GTK. E.g. 2.24.10 in this case.

set GTK=c:/temp/GTK
gcc -c -mms-bitfields -I%gtk%/lib/gtk-2.0/include -I%gtk%/lib/gdk-2.0/include -I%gtk%/lib/glib-2.0/include -I%gtk%/include -I%gtk%/include/atk-1.0 -I%gtk%/include/gdk-pixbuf-2.0 -I%gtk%/include/cairo -I%gtk%/include/pango-1.0 -I%gtk%/include/gio-win32-2.0 -I%gtk%/include/glib-2.0 -I%gtk%/include/gtk-2.0 test.c
gcc test.o --mwindows -Wl,-luuid -L%gtk%/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -lgobject-2.0 -lglib-2.0 -o test.exe

Any thoughts? What is broken here GTK, gcc, MinGW? Some compiler/linker options missed?

解决方案

This was GTK bug 685959. Most of the leak was fixed in GTK 2.24.14.

Bug 707760 tracks the packages (binaries, bundle) update.

这篇关于gtk_widget_queue_draw中,Windows 7下的内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆