0
對不起,這是一個愚蠢的問題。我最近在一個可執行文件上運行valgrind來查找內存泄漏。在Valgrind的內存泄漏報告,它顯示了以下爲可能丟失:如何在Eclipse IDE中添加GLIBCXX_FORCE_NEW來解決Valgrind字符串泄漏問題?
==20425== 64 bytes in 1 blocks are possibly lost in loss record 520 of 580
==20425== at 0x4029FDE: operator new(unsigned int) (vg_replace_malloc.c:313)
==20425== by 0x415F213: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.19)
==20425== by 0x4161125: char* std::string::_S_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.19)
==20425== by 0x41617AF: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.19)
==20425== by 0x804B805: test() (MyApp.cpp:228)
通過堆棧溢出看完之後,似乎這種「串」錯誤報告是由一個內存池優化造成的,Valgrind的不喜歡它。建議使用GLIBCXX_FORCE_NEW來修復它。我如何配置Eclipse IDE以在編譯期間使用它?