gpt4 book ai didi

linux - 解码 Valgrind 输出

转载 作者:太空宇宙 更新时间:2023-11-04 03:36:59 25 4
gpt4 key购买 nike

启用内存泄漏后 valgrind 的输出如下所示。
从堆栈跟踪中,如何找到内存泄漏的位置?难道是libpq.so吗?

==8909== 
==8909== HEAP SUMMARY:
==8909== in use at exit: 373,468 bytes in 2,997 blocks
==8909== total heap usage: 30,367 allocs, 27,370 frees, 5,535,985 bytes allocated
==8909==
==8909== 123,640 (11,000 direct, 112,640 indirect) bytes in 55 blocks are definitely lost in loss record 290 of 291
==8909== at 0x4C2B3F8: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8909== by 0x52919F3: PQmakeEmptyPGresult (in /usr/lib/libpq.so.5.4)
==8909== by 0x529BA40: ??? (in /usr/lib/libpq.so.5.4)
==8909== by 0x5293767: PQgetResult (in /usr/lib/libpq.so.5.4)
==8909== by 0x5293AB7: ??? (in /usr/lib/libpq.so.5.4)
==8909== by 0x416B29: readTable() (thread.cpp:366)
==8909== by 0x40D018: _ZNSt12_Bind_simpleIFPFvvEvEE9_M_invokeIIEEEvSt12_Index_tupleIIXspT_EEE (functional:1732)
==8909== by 0x40CC94: std::_Bind_simple<void (*()())()>::operator()() (functional:1720)
==8909== by 0x40CB55: std::thread::_Impl<std::_Bind_simple<void (*()())()> >::_M_run() (thread:115)
==8909== by 0x5560ABF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.17)
==8909== by 0x65B9E99: start_thread (pthread_create.c:308)
==8909== by 0x5ABB3FC: clone (clone.S:112)
==8909==
==8909== 123,640 (11,000 direct, 112,640 indirect) bytes in 55 blocks are definitely lost in loss record 291 of 291
==8909== at 0x4C2B3F8: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8909== by 0x52919F3: PQmakeEmptyPGresult (in /usr/lib/libpq.so.5.4)
==8909== by 0x529BA40: ??? (in /usr/lib/libpq.so.5.4)
==8909== by 0x5293767: PQgetResult (in /usr/lib/libpq.so.5.4)
==8909== by 0x5293AB7: ??? (in /usr/lib/libpq.so.5.4)
==8909== by 0x416E55: readTable() (thread.cpp:405)
==8909== by 0x40D018: _ZNSt12_Bind_simpleIFPFvvEvEE9_M_invokeIIEEEvSt12_Index_tupleIIXspT_EEE (functional:1732)
==8909== by 0x40CC94: std::_Bind_simple<void (*()())()>::operator()() (functional:1720)
==8909== by 0x40CB55: std::thread::_Impl<std::_Bind_simple<void (*()())()> >::_M_run() (thread:115)
==8909== by 0x5560ABF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.17)
==8909== by 0x65B9E99: start_thread (pthread_create.c:308)
==8909== by 0x5ABB3FC: clone (clone.S:112)
==8909==
==8909== LEAK SUMMARY:
==8909== definitely lost: 22,000 bytes in 110 blocks
==8909== indirectly lost: 225,280 bytes in 110 blocks
==8909== possibly lost: 0 bytes in 0 blocks
==8909== still reachable: 126,188 bytes in 2,777 blocks
==8909== suppressed: 0 bytes in 0 blocks
==8909== Reachable blocks (those to which a pointer was found) are not shown.
==8909== To see them, rerun with: --leak-check=full --show-reachable=yes
==8909==
==8909== For counts of detected and suppressed errors, rerun with: -v
==8909== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 2 from 2)

预先感谢您的帮助。

最佳答案

尝试attaching gdb to valgrind然后在您认为可能发生泄漏的位置设置断点。然后,运行monitorleak_check以查看是否丢失了任何内容。据我所知,您无法在失去内存时设置断点,但您可以单步执行程序直到您设置断点。

关于linux - 解码 Valgrind 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31249506/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com