我有内存泄漏吗?

时间:2012-09-01 05:46:56

标签: c++ memory valgrind

  

可能重复:
  Leak in Exception Code C++

我在某些代码上运行了valgrind(下面),我对它的输出感到困惑,声称我的内存泄漏很小。这是输出;我找不到问题。

代码:

121         std::cerr << "exp "<<i<<" ";
122         exp->print(std::cerr);
123         std::cerr << std::endl;

输出:

==27313== 16 bytes in 1 blocks are definitely lost in loss record 1 of 6
==27313==    at 0x1000525CF: malloc (vg_replace_malloc.c:266)
==27313==    by 0x1000A90CF: __cxa_get_globals (in /usr/lib/libstdc++.6.0.9.dylib)
==27313==    by 0x1000A8EA9: std::uncaught_exception() (in /usr/lib/libstdc++.6.0.9.dylib)
==27313==    by 0x100088096: std::ostream::sentry::~sentry() (in /usr/lib/libstdc++.6.0.9.dylib)
==27313==    by 0x100088BF9: std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char
> >&, char const*, long) (in /usr/lib/libstdc++.6.0.9.dylib)
==27313==    by 0x100088C57: std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char 
const*) (in /usr/lib/libstdc++.6.0.9.dylib)
==27313==    by 0x1000028C4: test() (foo.cpp:121)
==27313==    by 0x100002D92: main (foo.cpp:35)

请注意,调用exp-&gt; print只会做更多相同的事情;我打印了一些散布着字符串常量的值。

0 个答案:

没有答案