fqucuo
fqucuo
采纳率100%
2015-11-09 15:13 阅读 1.7k
已采纳

boost filesystem memory leak!

int main(int argc, char* argv[])
{
    _CrtSetBreakAlloc(284);
    {
        boost::filesystem::path p(argv[0]);
        std::string b = p.extension().generic_string();;
    }
    _CrtDumpMemoryLeaks();
    return 0;
}

下面是output显示的内容, 分两部分, 一部分是用_CrtDumpMemoryLeaks()显示的两个泄漏点, 这两个点分别是extension()里用到的path, 从内存申请点断点来看, 确实没有释放; 另外我安装了最新版的Visual Leak Detector, 却显示没有泄漏

 Visual Leak Detector Version 2.4RC2 installed.
Detected memory leaks!
Dumping objects ->
{296} normal block at 0x0081D8E0, 8 bytes long.
 Data: <0 1     > 30 16 31 00 00 00 00 00 
{282} normal block at 0x0081BFD0, 8 bytes long.
 Data: <  1     > 08 16 31 00 00 00 00 00 
Object dump complete.
The thread 0x78 has exited with code 0 (0x0).
The thread 0x2fa4 has exited with code 0 (0x0).
The thread 0x6b0 has exited with code 0 (0x0).
No memory leaks detected.
Visual Leak Detector is now exiting.
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    fqucuo fqucuo 2015-11-09 15:32

    问题找到了, extension会调用到dot_path函数, 里面有一个static path, 所以在main内还是显示没释放, 正常

    点赞 评论 复制链接分享

相关推荐