短時間の間、私はGTK-3.0
を学び始めました。私が働くプログラムのGUIを作成し始めました。いくつかのメモリリークを伴うGTKのGUI
プログラムは警告なしでコンパイルされますが、valgrind
で実行すると、メモリリークが多く発生し、私が何をやっているのか分かりません。
私は自分のプログラムを最小限のコードに減らしました。問題を簡単に説明できるようにしました。以下のコードに
は細かいが、メモリリークの多くでコンパイル:
#include <gtk/gtk.h>
int main(int argc, char *argv[]){
gtk_init(&argc, &argv);
GtkWidget *window;
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), NULL);
gtk_widget_show(window);
gtk_main();
}
私はそれをコンパイル:
gcc -Wpedantic -std=c11 -Wall -Wextra -Werror -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wconversion -Wshadow -Winit-self -Wfloat-equal -Wwrite-strings -O0 -g main.c -o app `pkg-config --cflags gtk+-3.0 ` `pkg-config --libs gtk+-3.0 `
と、私は次のコマンドでvalgrind
を実行した後:
valgrind --leak-check=full --track-origins=yes --leak-check=full ./app
私は以下の出力を得ます:
==14405== Memcheck, a memory error detector
==14405== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==14405== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==14405== Command: ./app
==14405==
==14405==
==14405== HEAP SUMMARY:
==14405== in use at exit: 1,243,902 bytes in 12,774 blocks
==14405== total heap usage: 80,535 allocs, 67,761 frees, 6,190,649 bytes allocated
==14405==
==14405== 16 bytes in 1 blocks are possibly lost in loss record 1,279 of 5,945
==14405== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x86E2780: g_malloc0 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x5796522: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x579AF90: g_type_register_fundamental (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x577A30B: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5774177: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x40104E9: call_init.part.0 (dl-init.c:72)
==14405== by 0x40105FA: call_init (dl-init.c:30)
==14405== by 0x40105FA: _dl_init (dl-init.c:120)
==14405== by 0x4000CF9: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
==14405==
==14405== 16 bytes in 1 blocks are possibly lost in loss record 1,280 of 5,945
==14405== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x4C2FDEF: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x86E27E7: g_realloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x5796406: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x579AF90: g_type_register_fundamental (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x577A30B: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5774177: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x40104E9: call_init.part.0 (dl-init.c:72)
==14405== by 0x40105FA: call_init (dl-init.c:30)
==14405== by 0x40105FA: _dl_init (dl-init.c:120)
==14405== by 0x4000CF9: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
==14405==
==14405== 16 bytes in 1 blocks are possibly lost in loss record 1,281 of 5,945
==14405== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x86E2780: g_malloc0 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x5796522: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x579AF90: g_type_register_fundamental (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x577A371: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5774177: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x40104E9: call_init.part.0 (dl-init.c:72)
==14405== by 0x40105FA: call_init (dl-init.c:30)
==14405== by 0x40105FA: _dl_init (dl-init.c:120)
==14405== by 0x4000CF9: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
==14405==
==14405== 16 bytes in 1 blocks are possibly lost in loss record 1,282 of 5,945
==14405== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x4C2FDEF: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x86E27E7: g_realloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x5796406: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x579AF90: g_type_register_fundamental (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x577A371: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5774177: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x40104E9: call_init.part.0 (dl-init.c:72)
==14405== by 0x40105FA: call_init (dl-init.c:30)
==14405== by 0x40105FA: _dl_init (dl-init.c:120)
==14405== by 0x4000CF9: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
==14405==
==14405== 16 bytes in 1 blocks are possibly lost in loss record 1,283 of 5,945
==14405== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x86E2780: g_malloc0 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x5796522: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x579AF90: g_type_register_fundamental (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5783B04: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5774181: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x40104E9: call_init.part.0 (dl-init.c:72)
==14405== by 0x40105FA: call_init (dl-init.c:30)
==14405== by 0x40105FA: _dl_init (dl-init.c:120)
==14405== by 0x4000CF9: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
==14405==
==14405== 16 bytes in 1 blocks are possibly lost in loss record 1,284 of 5,945
==14405== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x4C2FDEF: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x86E27E7: g_realloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x5796406: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x579AF90: g_type_register_fundamental (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5783B04: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5774181: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x40104E9: call_init.part.0 (dl-init.c:72)
==14405== by 0x40105FA: call_init (dl-init.c:30)
==14405== by 0x40105FA: _dl_init (dl-init.c:120)
==14405== by 0x4000CF9: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
==14405==
==14405== 16 bytes in 1 blocks are possibly lost in loss record 1,285 of 5,945
==14405== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x86E2780: g_malloc0 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x5796522: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x579AF90: g_type_register_fundamental (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x577EC1B: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5774186: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x40104E9: call_init.part.0 (dl-init.c:72)
==14405== by 0x40105FA: call_init (dl-init.c:30)
==14405== by 0x40105FA: _dl_init (dl-init.c:120)
==14405== by 0x4000CF9: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
==14405==
==14405== 16 bytes in 1 blocks are possibly lost in loss record 1,286 of 5,945
==14405== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x4C2FDEF: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x86E27E7: g_realloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x5796406: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x579AF90: g_type_register_fundamental (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x577EC1B: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5774186: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x40104E9: call_init.part.0 (dl-init.c:72)
==14405== by 0x40105FA: call_init (dl-init.c:30)
==14405== by 0x40105FA: _dl_init (dl-init.c:120)
==14405== by 0x4000CF9: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
==14405==
==14405== 24 bytes in 1 blocks are possibly lost in loss record 1,808 of 5,945
==14405== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x86E2780: g_malloc0 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x57993B5: g_type_class_ref (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5798E2C: g_type_class_ref (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5788147: g_param_spec_flags (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5191F6F: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.1800.9)
==14405== by 0x579922C: g_type_class_ref (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x4EBFC49: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.1800.9)
==14405== by 0x7532A1D: atk_add_focus_tracker (in /usr/lib/x86_64-linux-gnu/libatk-1.0.so.0.21809.1)
==14405== by 0x4EC0084: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.1800.9)
==14405== by 0x5778FA4: g_closure_invoke (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x578AFC0: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405==
==14405== 32 bytes in 1 blocks are possibly lost in loss record 2,824 of 5,945
==14405== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x86E2780: g_malloc0 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x57993B5: g_type_class_ref (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5798E2C: g_type_class_ref (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5788057: g_param_spec_enum (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5FCBAFE: ??? (in /usr/lib/x86_64-linux-gnu/libgdk-3.so.0.1800.9)
==14405== by 0x579922C: g_type_class_ref (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5798E2C: g_type_class_ref (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x57803A3: g_object_new_valist (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5780520: g_object_new (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5FF16DD: ??? (in /usr/lib/x86_64-linux-gnu/libgdk-3.so.0.1800.9)
==14405== by 0x5FF3E21: ??? (in /usr/lib/x86_64-linux-gnu/libgdk-3.so.0.1800.9)
==14405==
==14405== 56 bytes in 1 blocks are possibly lost in loss record 3,553 of 5,945
==14405== at 0x4C2FD5F: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x86E27E7: g_realloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x57959D8: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x579B2CC: g_type_register_static (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x577A53D: g_flags_register_static (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x50A2D0A: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.1800.9)
==14405== by 0x4FB9264: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.1800.9)
==14405== by 0x579922C: g_type_class_ref (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x57803A3: g_object_new_valist (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5780520: g_object_new (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x4FBAAB7: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.1800.9)
==14405== by 0x4FBAE82: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.1800.9)
==14405==
==14405== 80 bytes in 1 blocks are possibly lost in loss record 4,221 of 5,945
==14405== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x86E2780: g_malloc0 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x57993B5: g_type_class_ref (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5798E2C: g_type_class_ref (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x579C247: g_type_create_instance (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x57840D2: g_param_spec_internal (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5788661: g_param_spec_object (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5FD1231: ??? (in /usr/lib/x86_64-linux-gnu/libgdk-3.so.0.1800.9)
==14405== by 0x579922C: g_type_class_ref (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x577FDAC: g_object_newv (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5780533: g_object_new (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5FD1324: gdk_display_manager_get (in /usr/lib/x86_64-linux-gnu/libgdk-3.so.0.1800.9)
==14405==
==14405== 96 bytes in 1 blocks are possibly lost in loss record 5,132 of 5,945
==14405== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x86E2780: g_malloc0 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x5795A59: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5795B43: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x57740AA: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x40104E9: call_init.part.0 (dl-init.c:72)
==14405== by 0x40105FA: call_init (dl-init.c:30)
==14405== by 0x40105FA: _dl_init (dl-init.c:120)
==14405== by 0x4000CF9: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
==14405==
==14405== 96 bytes in 1 blocks are possibly lost in loss record 5,133 of 5,945
==14405== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x86E2780: g_malloc0 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x5795A59: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5795B43: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x579AF82: g_type_register_fundamental (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x577A30B: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5774177: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x40104E9: call_init.part.0 (dl-init.c:72)
==14405== by 0x40105FA: call_init (dl-init.c:30)
==14405== by 0x40105FA: _dl_init (dl-init.c:120)
==14405== by 0x4000CF9: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
==14405==
==14405== 96 bytes in 1 blocks are possibly lost in loss record 5,134 of 5,945
==14405== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x86E2780: g_malloc0 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x5795A59: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5795B43: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x579AF82: g_type_register_fundamental (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x577A371: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5774177: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x40104E9: call_init.part.0 (dl-init.c:72)
==14405== by 0x40105FA: call_init (dl-init.c:30)
==14405== by 0x40105FA: _dl_init (dl-init.c:120)
==14405== by 0x4000CF9: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
==14405==
==14405== 96 bytes in 1 blocks are possibly lost in loss record 5,135 of 5,945
==14405== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x86E2780: g_malloc0 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x5795A59: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5795B43: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x579AF82: g_type_register_fundamental (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5783B04: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5774181: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x40104E9: call_init.part.0 (dl-init.c:72)
==14405== by 0x40105FA: call_init (dl-init.c:30)
==14405== by 0x40105FA: _dl_init (dl-init.c:120)
==14405== by 0x4000CF9: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
==14405==
==14405== 96 bytes in 1 blocks are possibly lost in loss record 5,136 of 5,945
==14405== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x86E2780: g_malloc0 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x5795A59: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5795B43: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x579AF82: g_type_register_fundamental (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x577EC1B: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5774186: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x40104E9: call_init.part.0 (dl-init.c:72)
==14405== by 0x40105FA: call_init (dl-init.c:30)
==14405== by 0x40105FA: _dl_init (dl-init.c:120)
==14405== by 0x4000CF9: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
==14405==
==14405== 132 bytes in 1 blocks are possibly lost in loss record 5,413 of 5,945
==14405== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x86E2780: g_malloc0 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x5796DFF: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x579AFE0: g_type_register_fundamental (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x577A30B: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5774177: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x40104E9: call_init.part.0 (dl-init.c:72)
==14405== by 0x40105FA: call_init (dl-init.c:30)
==14405== by 0x40105FA: _dl_init (dl-init.c:120)
==14405== by 0x4000CF9: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
==14405==
==14405== 132 bytes in 1 blocks are possibly lost in loss record 5,414 of 5,945
==14405== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x86E2780: g_malloc0 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x5796DFF: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x579AFE0: g_type_register_fundamental (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x577A371: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5774177: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x40104E9: call_init.part.0 (dl-init.c:72)
==14405== by 0x40105FA: call_init (dl-init.c:30)
==14405== by 0x40105FA: _dl_init (dl-init.c:120)
==14405== by 0x4000CF9: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
==14405==
==14405== 148 bytes in 1 blocks are possibly lost in loss record 5,457 of 5,945
==14405== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x86E2780: g_malloc0 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x5796BD6: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x579AFE0: g_type_register_fundamental (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5783B04: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5774181: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x40104E9: call_init.part.0 (dl-init.c:72)
==14405== by 0x40105FA: call_init (dl-init.c:30)
==14405== by 0x40105FA: _dl_init (dl-init.c:120)
==14405== by 0x4000CF9: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
==14405==
==14405== 148 bytes in 1 blocks are possibly lost in loss record 5,458 of 5,945
==14405== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x86E2780: g_malloc0 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x5796BD6: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x579AFE0: g_type_register_fundamental (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x577EC1B: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5774186: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x40104E9: call_init.part.0 (dl-init.c:72)
==14405== by 0x40105FA: call_init (dl-init.c:30)
==14405== by 0x40105FA: _dl_init (dl-init.c:120)
==14405== by 0x4000CF9: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
==14405==
==14405== 176 bytes in 4 blocks are possibly lost in loss record 5,513 of 5,945
==14405== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x86E2728: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x4FA7173: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.1800.9)
==14405== by 0x4FA7439: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.1800.9)
==14405== by 0x4FA622C: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.1800.9)
==14405== by 0x4F02766: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.1800.9)
==14405== by 0x4F03FE4: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.1800.9)
==14405== by 0x4F0425D: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.1800.9)
==14405== by 0x577E896: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x57801B4: g_object_new_valist (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5780520: g_object_new (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x4F02D27: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.1800.9)
==14405==
==14405== 184 bytes in 1 blocks are possibly lost in loss record 5,528 of 5,945
==14405== at 0x4C2FD5F: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x86E27E7: g_realloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x57959D8: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x579B2CC: g_type_register_static (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5785799: g_param_type_register_static (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5787AFB: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x577418B: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x40104E9: call_init.part.0 (dl-init.c:72)
==14405== by 0x40105FA: call_init (dl-init.c:30)
==14405== by 0x40105FA: _dl_init (dl-init.c:120)
==14405== by 0x4000CF9: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
==14405==
==14405== 200 bytes in 5 blocks are possibly lost in loss record 5,549 of 5,945
==14405== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x86E2728: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x86FB537: g_memdup (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x4FA7109: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.1800.9)
==14405== by 0x4FA7387: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.1800.9)
==14405== by 0x4FA61EC: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.1800.9)
==14405== by 0x50EFD11: gtk_style_context_set_state (in /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.1800.9)
==14405== by 0x4F03EE4: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.1800.9)
==14405== by 0x4F0425D: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.1800.9)
==14405== by 0x577E896: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x57801B4: g_object_new_valist (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405== by 0x5780520: g_object_new (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.1)
==14405==
==14405== 336 bytes in 1 blocks are possibly lost in loss record 5,673 of 5,945
==14405== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14405== by 0x40136D4: allocate_dtv (dl-tls.c:322)
==14405== by 0x40136D4: _dl_allocate_tls (dl-tls.c:539)
==14405== by 0x59C42AE: allocate_stack (allocatestack.c:588)
==14405== by 0x59C42AE: [email protected]@GLIBC_2.2.5 (pthread_create.c:539)
==14405== by 0x87218AF: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x8703E9E: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x8703F57: g_thread_new (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x86DE280: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1)
==14405== by 0x8392E16: g_task_get_type (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.4800.1)
==14405== by 0x83F0610: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.4800.1)
==14405== by 0x83E4216: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.4800.1)
==14405==
==14405==
==14405== LEAK SUMMARY:
==14405== definitely lost: 0 bytes in 0 blocks
==14405== indirectly lost: 0 bytes in 0 blocks
==14405== possibly lost: 3,544 bytes in 35 blocks
==14405== still reachable: 1,160,006 bytes in 12,091 blocks
==14405== of which reachable via heuristic:
==14405== length64 : 4,080 bytes in 72 blocks
==14405== newarray : 2,112 bytes in 52 blocks
==14405== suppressed: 0 bytes in 0 blocks
==14405== Reachable blocks (those to which a pointer was found) are not shown.
==14405== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==14405==
==14405== For counts of detected and suppressed errors, rerun with: -v
==14405== ERROR SUMMARY: 28 errors from 28 contexts (suppressed: 0 from 0)
私が本を読んだ後、GTK3 Manualに続いて、どこに漏れがあるのか分かります。
私はここでGUIを間違って始めましたか?マニュアルから、私はそれが正しい方法でコード化されていると確信しています。
valgrind
出力では、calloc
とrealloc
がコールされたことがわかります。これは、free()
コールが必要であることを意味します。 GTK +でメモリを解放するにはどうしたらいいですか?
私はここでもインターネット上にあると言っていますが、例はありません。あなたの答えに例を挙げてください。私が作成しようとしているプログラムは、すべてがうまくいくなら、少なくとも45日間走ります。だから私はこれを修正する必要があります。 – Michi