我正在使用valgrind --leak-check=yes调试我的C ++应用程序,并且我收到了很多关于可能的内存泄漏的信息。 这是使用Qt,POSIX线程和QuantLib的C ++应用程序。 我认为信息不正确,我已经测试了它,即使应用程序是非常简单的Qt应用程序,我也得到了很多这些信息。 可能valgrind错误解释了关于Qt和POSIX线程的内存信息。
我的问题是我该怎么做,如何正确调试这个Qt应用程序,理想情况下使用valgrind,但如果可能的话可能会采用不同的方式?
==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==
//还有更多,最后总结:
==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)