4

I am debugging my C++ application with valgrind --leak-check=yes and I am getting a lot of information about possible memory leaks. This is C++ application that uses Qt, POSIX threads and QuantLib. I think the information is not correct and I have tested it and I got a lot of these info even if app is very simple Qt app that does nothing. Probably valgrind is misinterpreting memory info being confused about Qt and POSIX threads.

My question is what can I do, how to debug this Qt app correctly, ideally using valgrind, but maybe different way if possible?

==9419== Memcheck, a memory error detector
==9419== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==9419== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==9419== Command: ./qt_tradingclient_1
==9419== Parent PID: 19797
==9419== 
==9419== 
==9419== HEAP SUMMARY:
==9419==     in use at exit: 1,587,688 bytes in 10,156 blocks
==9419==   total heap usage: 365,203 allocs, 355,047 frees, 92,510,461 bytes allocated
==9419== 
==9419== 1 bytes in 1 blocks are possibly lost in loss record 3 of 5,210
==9419==    at 0x4C2B3F8: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==9419==    by 0x8AC36E0: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3400.1)
==9419==    by 0x8AD9F5B: g_strdup (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3400.1)
==9419==    by 0x88461DB: g_param_spec_string (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.3400.1)
==9419==    by 0x1153F1B7: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.13)
==9419==    by 0x8855925: g_type_class_ref (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.3400.1)
==9419==    by 0x883DDF0: g_object_newv (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.3400.1)
==9419==    by 0x883E38B: g_object_new (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.3400.1)
==9419==    by 0x1153D7DF: gtk_settings_get_for_screen (in /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.13)
==9419==    by 0x114EC298: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.13)
==9419==    by 0x883A5C3: g_cclosure_marshal_VOID__OBJECTv (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.3400.1)
==9419==    by 0x8837406: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.3400.1)
==9419== 
==9419== 1 bytes in 1 blocks are possibly lost in loss record 4 of 5,210
==9419==    at 0x4C2B3F8: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==9419==    by 0x8AC36E0: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3400.1)
==9419==    by 0x8AD9F5B: g_strdup (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3400.1)
==9419==    by 0x88461DB: g_param_spec_string (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.3400.1)
==9419==    by 0x114E1933: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.13)
==9419==    by 0x8855925: g_type_class_ref (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.3400.1)
==9419==    by 0x170E3225: ??? (in /usr/lib/x86_64-linux-gnu/gtk-2.0/modules/libcanberra-gtk-module.so)
==9419==    by 0x170E4FB1: gtk_module_init (in /usr/lib/x86_64-linux-gnu/gtk-2.0/modules/libcanberra-gtk-module.so)
==9419==    by 0x114EB7F0: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.13)
==9419==    by 0x883713F: g_closure_invoke (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.3400.1)
==9419==    by 0x884854F: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.3400.1)
==9419==    by 0x88504AE: g_signal_emit_valist (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.3400.1)
==9419== 

//and many more, and finally summary:

==9419== 32,768 bytes in 16 blocks are possibly lost in loss record 5,208 of 5,210
==9419==    at 0x4C2B4F0: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==9419==    by 0x8AC377E: g_realloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3400.1)
==9419==    by 0x8A931C2: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3400.1)
==9419==    by 0x8A93632: g_array_insert_vals (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3400.1)
==9419==    by 0x1151B084: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.13)
==9419==    by 0x1151B289: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.13)
==9419==    by 0x16EBA76B: ??? (in /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/engines/libmurrine.so)
==9419==    by 0x1151CBF0: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.13)
==9419==    by 0x11521066: gtk_rc_get_style (in /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.13)
==9419==    by 0x115F2BEF: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.13)
==9419==    by 0x115F35BD: gtk_widget_realize (in /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.13)
==9419==    by 0x115F4187: gtk_widget_set_parent (in /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.13)
==9419== 
==9419== LEAK SUMMARY:
==9419==    definitely lost: 5,759 bytes in 31 blocks
==9419==    indirectly lost: 12,804 bytes in 396 blocks
==9419==      possibly lost: 482,706 bytes in 2,236 blocks
==9419==    still reachable: 1,086,419 bytes in 7,493 blocks
==9419==         suppressed: 0 bytes in 0 blocks
==9419== Reachable blocks (those to which a pointer was found) are not shown.
==9419== To see them, rerun with: --leak-check=full --show-reachable=yes
==9419== 
==9419== For counts of detected and suppressed errors, rerun with: -v
==9419== ERROR SUMMARY: 812 errors from 812 contexts (suppressed: 3 from 3)
4pie0
  • 29,204
  • 9
  • 82
  • 118
  • The valgrind output for a trivial Qt app is already answered at [Is anyone using valgrind and Qt?](http://stackoverflow.com/questions/1593717/is-anyone-using-valgrind-and-qt) – Daniel Vérité Jun 28 '13 at 16:25
  • no, there is no answer to my question there. How can I debug this and avoid false reports? – 4pie0 Jun 28 '13 at 16:39
  • Possible duplicate of [Is anyone using valgrind and Qt?](http://stackoverflow.com/questions/1593717/is-anyone-using-valgrind-and-qt) – malat Jan 11 '17 at 08:43

1 Answers1

0

If you are sure that your application is leaking memory but it is not detected in Valgrind, then perhaps Velgrind is finding some problem to load your application.

If you are not sure, then it is possible that the library you are using leaks memory and it should be Ok.