内存泄漏“多线程调试” (/ MTd)并且没有“多线程调试DLL”泄漏(/ MDD) [英] Memory leaks with "Multi-Threaded Debug" (/MTd) and no leaks with "Multi-Threaded Debug DLL" (/MDd)

查看:109
本文介绍了内存泄漏“多线程调试” (/ MTd)并且没有“多线程调试DLL”泄漏(/ MDD)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 我在解决方案中有一堆库和项目,我改为使用/ MTd而不是/ MDd。我正在使用VS2008。

  I have a bunch of libraries and projects in a solution that I changed to using /MTd instead of /MDd. I'm using VS2008.

我突然得到了一大堆内存泄漏,而这些泄漏是/ MTd开关不存在的。

I suddenly get a whole bunch of memory leaks that did not exist with the /MTd switch.

使用  < a href ="https://vld.codeplex.com/"> Visual Leak Detector ,我注意到所有漏洞都是各种库的内部漏洞,包括CRT,VS库和boost。

Using Visual Leak Detector, I noticed that all the leaks are internal to various libraries, including CRT, VS libraries and boost.

例如,这里是前3个泄漏的调用堆栈(项目是Boost :: Test项目):

For example, here the call-stacks of the first 3 leaks (the project is a Boost::Test project):

---------- Block 1 at 0x02211EA0: 568 bytes ----------
  Call Stack:
    f:\dd\vctools\crt_bld\self_x86\crt\src\tidtable.c (395): FrameworkUnitTests.exe!_mtinit + 0x18 bytes
    f:\dd\vctools\crt_bld\self_x86\crt\src\crt0.c (215): FrameworkUnitTests.exe!__tmainCRTStartup + 0x5 bytes
    f:\dd\vctools\crt_bld\self_x86\crt\src\crt0.c (182): FrameworkUnitTests.exe!mainCRTStartup
    0x7C817077 (File and line number not available): kernel32.dll!RegisterWaitForInputIdle + 0x49 bytes
  Data:
    00 00 00 00    F0 20 21 02    0C 9D B8 00    8A 01 00 00     ......!. ........
    14 02 00 00    02 00 00 00    01 00 00 00    FD FD FD FD     ........ ........
    84 1B 00 00    FF FF FF FF    22 00 00 00    02 00 00 00     ........ ".......
    00 00 00 00    C5 03 8A E6    00 00 00 00    00 00 00 00     ........ ........
    00 00 00 00    00 00 00 00    00 00 00 00    00 00 00 00     ........ ........
    00 00 00 00    00 00 00 00    00 00 00 00    00 00 00 00     ........ ........
    00 00 00 00    B0 80 8C 03    00 00 00 00    00 00 00 00     ........ ........
    00 00 00 00    00 00 00 00    00 00 00 00    E8 C9 B8 00     ........ ........
    00 00 00 00    00 00 00 00    B0 4A 21 02    F8 DB C4 00     ........ .J!.....
    01 00 00 00    00 00 00 00    00 00 00 00    00 00 00 00     ........ ........
    D0 57 99 00    00 00 00 00    00 00 00 00    00 00 00 00     .W...... ........
    00 00 00 00    00 00 00 00    00 00 00 00    00 00 00 00     ........ ........
    00 00 00 00    00 00 00 00    00 00 00 00    00 00 00 00     ........ ........
    00 00 00 00    00 00 00 00    00 00 00 00    00 00 00 00     ........ ........
    00 00 00 00    00 00 00 00    43 00 00 00    00 00 00 00     ........ C.......
    00 00 00 00    00 00 00 00    00 00 00 00    00 00 00 00     ........ ........


---------- Block 2 at 0x022120F0: 2084 bytes ----------
  Call Stack:
    f:\dd\vctools\crt_bld\self_x86\crt\src\ioinit.c (137): FrameworkUnitTests.exe!_ioinit + 0x15 bytes
    f:\dd\vctools\crt_bld\self_x86\crt\src\crt0.c (235): FrameworkUnitTests.exe!__tmainCRTStartup + 0x5 bytes
    f:\dd\vctools\crt_bld\self_x86\crt\src\crt0.c (182): FrameworkUnitTests.exe!mainCRTStartup
    0x7C817077 (File and line number not available): kernel32.dll!RegisterWaitForInputIdle + 0x49 bytes
  Data:
    A0 1E 21 02    90 4A 21 02    A4 C4 B8 00    88 00 00 00     ..!..J!. ........
    00 08 00 00    02 00 00 00    02 00 00 00    FD FD FD FD     ........ ........
    03 00 00 00    C1 0A 00 00    01 00 00 00    00 F8 15 00     ........ ........
    FF FF FF FF    00 00 00 00    00 00 00 00    00 00 00 00     ........ ........
    A0 0F 00 00    00 0A 0A 00    00 00 00 00    00 00 00 00     ........ ........
    00 00 00 00    00 00 00 00    00 00 00 00    00 00 00 00     ........ ........
    07 00 00 00    C1 0A 00 00    01 00 00 00    38 F8 15 00     ........ ....8...
    FF FF FF FF    00 00 00 00    00 00 00 00    00 00 00 00     ........ ........
    A0 0F 00 00    00 0A 0A 00    00 00 00 00    00 00 00 00     ........ ........
    00 00 00 00    00 00 00 00    00 00 00 00    00 00 00 00     ........ ........
    0B 00 00 00    C1 0A 00 00    01 00 00 00    70 F8 15 00     ........ ....p...
    FF FF FF FF    00 00 00 00    00 00 00 00    00 00 00 00     ........ ........
    A0 0F 00 00    00 0A 0A 00    00 00 00 00    00 00 00 00     ........ ........
    00 00 00 00    00 00 00 00    00 00 00 00    00 00 00 00     ........ ........
    FF FF FF FF    00 0A 00 00    01 00 00 00    D8 FF 15 00     ........ ........
    FF FF FF FF    00 00 00 00    00 00 00 00    00 00 00 00     ........ ........


---------- Block 118 at 0x02212FC0: 60 bytes ----------
  Call Stack:
    f:\dd\vctools\crt_bld\self_x86\crt\src\mlock.c (279): FrameworkUnitTests.exe!_mtinitlocknum + 0x13 bytes
    f:\dd\vctools\langapi\undname\undname.cxx (649): FrameworkUnitTests.exe!__unDName + 0x7 bytes
    f:\dd\vctools\crt_bld\self_x86\crt\prebuild\eh\typname.cpp (124): FrameworkUnitTests.exe!type_info::_Name_base + 0x1F bytes
    f:\dd\vctools\crt_bld\self_x86\crt\prebuild\eh\typinfo.cpp (45): FrameworkUnitTests.exe!type_info::name + 0xD bytes
    c:\...\3rdpartylibs\boost_1_49_0\boost\test\unit_test_suite_impl.hpp (377): FrameworkUnitTests.exe!boost::unit_test::ut_detail::generate_test_case_4_type<boost::unit_test::ut_detail::template_test_case_gen<Bitset_b85_Serialization_Tests::deserialize_from_empty_string_should_fail_invoker,boost::mpl::vector_c<int,5,59,519,1021,1024,1025,1026,3021,7024,11 + 0xF bytes
    c:\...\3rdpartylibs\boost_1_49_0\boost\mpl\for_each.hpp (79): FrameworkUnitTests.exe!boost::mpl::aux::for_each_impl<0>::execute<boost::mpl::v_iter<boost::mpl::vector11<boost::mpl::integral_c<int,5>,boost::mpl::integral_c<int,59>,boost::mpl::integral_c<int,519>,boost::mpl::integral_c<int,1021>,boost::mpl::integral_c<int,1024>,boost::mpl::i
    c:\...\3rdpartylibs\boost_1_49_0\boost\mpl\for_each.hpp (101): FrameworkUnitTests.exe!boost::mpl::for_each<boost::mpl::vector_c<int,5,59,519,1021,1024,1025,1026,3021,7024,11025,22026,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647>,boost::mpl::make_identity<boost::mpl::arg<-1> >,boost::uni + 0x21 bytes
    c:...\3rdpartylibs\boost_1_49_0\boost\test\unit_test_suite_impl.hpp (405): FrameworkUnitTests.exe!boost::unit_test::ut_detail::template_test_case_gen<Bitset_b85_Serialization_Tests::deserialize_from_empty_string_should_fail_invoker,boost::mpl::vector_c<int,5,59,519,1021,1024,1025,1026,3021,7024,11025,22026,2147483647,2147483647,2147483647,2147483647,2 + 0x35 bytes
    c:\...\src\bitset_serialization_test.cpp (31): FrameworkUnitTests.exe!Bitset_b85_Serialization_Tests::`dynamic initializer for 'deserialize_from_empty_string_should_fail_registrar31'' + 0x5D bytes
    f:\dd\vctools\crt_bld\self_x86\crt\src\crt0dat.c (903): FrameworkUnitTests.exe!_initterm
    f:\dd\vctools\crt_bld\self_x86\crt\src\crt0dat.c (307): FrameworkUnitTests.exe!_cinit + 0xF bytes
    f:\dd\vctools\crt_bld\self_x86\crt\src\crt0.c (249): FrameworkUnitTests.exe!__tmainCRTStartup + 0x7 bytes
    f:\dd\vctools\crt_bld\self_x86\crt\src\crt0.c (182): FrameworkUnitTests.exe!mainCRTStartup
    0x7C817077 (File and line number not available): kernel32.dll!RegisterWaitForInputIdle + 0x49 bytes
  Data:
    90 4A 21 02    78 40 21 02    5C 9B B8 00    17 01 00 00     .J!.x@!. \.......
    18 00 00 00    02 00 00 00    76 00 00 00    FD FD FD FD     ........ v.......
    F8 F9 15 00    FF FF FF FF    00 00 00 00    00 00 00 00     ........ ........
    00 00 00 00    A0 0F 00 00    FD FD FD FD                    ........ ........

请指教,

谢谢!

推荐答案

当您使用/ MDd时,您可以在exe中分配内存并将其释放到DLL中,因为所有模块正在使用一个常见的堆管理器。 但是对于/ MTd,每个模块都有单独的堆管理器,它们不合作。
When you use /MDd you can allocate memory in an exe and free it in a DLL because all modules are using one common heap manager.  But with /MTd there are seprate heap managers for each module, and they do not cooperate.


这篇关于内存泄漏“多线程调试” (/ MTd)并且没有“多线程调试DLL”泄漏(/ MDD)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆