gpt4 book ai didi

c++ - 使用 boost::test 进行内存泄漏检测

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:22:30 24 4
gpt4 key购买 nike

我尝试使用行号启用 msvc 内存泄漏检测,就像我发现的这个片段 here :

Detected memory leaks!
Dumping objects ->
C:\PROGRAM FILES\VISUAL STUDIO\MyProjects\leaktest\leaktest.cpp(20) : {18}
normal block at 0x00780E80, 64 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
Object dump complete.

我尝试设置预处理器定义

_CRTDBG_MAP_ALLOC

手动在项目属性中,但我只得到这个:

Dumping objects ->
{1466} normal block at 0x00BD4DD0, 40 bytes long.
Data: <(o; ; (o; 1 > 28 6F 3B 00 90 A9 3B 00 28 6F 3B 00 00 D6 31 10

没有行号。我还尝试使用 BOOST_TEST_NO_MAIN 手动定义 main 并像这样自己转储:

int main( int argc, char* argv[] )
{
int res = ::boost::unit_test::unit_test_main( &init_function, argc, argv );
_CrtDumpMemoryLeaks();
return res;
}

但也没有任何成功。如何做到这一点?

最佳答案

使用 Boost.Test 你可以使用 --detect_memory_leaks="allocation number"

关于c++ - 使用 boost::test 进行内存泄漏检测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7525330/

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