Re: Memory leak when using Gio::File



On Wed, 2012-08-22 at 09:19 +0600, Галымжан wrote:
> I have giomm 2.30.0 and glibmm 2.30.0. Test program:
> 
> 
> 
> 
> #include <iostream>
> #include <glibmm.h>
> #include <giomm.h>
> 
> 
> int main(int argc, char const *argv[]) {
>   g_type_init();
>   Glib::RefPtr<Gio::File> file =
> Gio::File::create_for_path("test.txt");
>   if (file->query_exists()) {
>     std::cout << "File is there" << std::endl;
>   }
>   return 0;
> }
> 
> 
> 
> 
> Compilation and running:
> 
> 
> 
> 
> > g++ giomm-test.cpp -o giomm-test `pkg-config --libs --cflags
> giomm-2.4`
> > valgrind --leak-check=full --show-possibly-lost=no giomm-test
> 
> 
> (process:3152): glibmm-CRITICAL **: Glib::ObjectBase*
> Glib::wrap_create_new_wrapper_for_interface(GObject*, GType):
> assertion `wrap_func_table != 0' failed
> 
> 
> (process:3152): GLib-GObject-CRITICAL **: g_object_set_qdata_full:
> assertion `quark > 0' failed
> ==3152== 
> ==3152== HEAP SUMMARY:
> ==3152==     in use at exit: 69,660 bytes in 956 blocks
> ==3152==   total heap usage: 1,569 allocs, 613 frees, 247,744 bytes
> allocated
> ==3152== 
> ==3152== 24 bytes in 1 blocks are definitely lost in loss record 370
> of 577
> ==3152==    at 0x402842F: operator new(unsigned int)
> (vg_replace_malloc.c:255)
> ==3152==    by 0x40CB4B6: Gio::File*
> Glib::wrap_auto_interface<Gio::File>(_GObject*, bool)
> (in /usr/lib/libgiomm-2.4.so.1.3.0)
> ==3152==    by 0x40CAB9E: Glib::wrap(_GFile*, bool)
> (in /usr/lib/libgiomm-2.4.so.1.3.0)
> ==3152==    by 0x42BE112: (below main) (libc-start.c:226)
> ==3152== 
> ==3152== 160 (40 direct, 120 indirect) bytes in 1 blocks are
> definitely lost in loss record 520 of 577
> ==3152==    at 0x4028876: malloc (vg_replace_malloc.c:236)
> ==3152==    by 0x438964C: nss_parse_service_list (nsswitch.c:626)
> ==3152==    by 0x4389C59: __nss_database_lookup (nsswitch.c:167)
> ==3152==    by 0x4C502F8: ???
> ==3152==    by 0x4C51A5D: ???
> ==3152==    by 0x4340956: getpwnam_r@@GLIBC_2.1.2 (getXXbyYY_r.c:256)
> ==3152==    by 0x4659695: ???
> (in /lib/i386-linux-gnu/libglib-2.0.so.0.3200.0)
> ==3152==    by 0x61687A6C: ???
> ==3152== 
> ==3152== LEAK SUMMARY:
> ==3152==    definitely lost: 64 bytes in 2 blocks
> ==3152==    indirectly lost: 120 bytes in 10 blocks
> ==3152==      possibly lost: 15,175 bytes in 268 blocks
> ==3152==    still reachable: 54,301 bytes in 676 blocks
> ==3152==         suppressed: 0 bytes in 0 blocks
> ==3152== Reachable blocks (those to which a pointer was found) are not
> shown.
> ==3152== To see them, rerun with: --leak-check=full
> --show-reachable=yes
> ==3152== 
> ==3152== For counts of detected and suppressed errors, rerun with: -v
> ==3152== ERROR SUMMARY: 92 errors from 92 contexts (suppressed: 69
> from 13)
> 
> 
> 
> 
> Why is there a memory leak? If I don't use Gio::File there is no
> memory leak.

Could you try with Gio::init() instead of g_type_init() and see if that
makes a difference?

> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> https://mail.gnome.org/mailman/listinfo/gtkmm-list

-- 
José



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]