2
我有一堆的庫和項目在一個解決方案,我改爲使用/ MTD/MDd。我正在使用VS2008。內存泄漏與「多線程調試」(/ MTd)和「多線程調試DLL」(/ MDd)沒有泄漏
我突然收到一大堆內存泄漏,這在/ MDd開關中並不存在。
使用Visual Leak Detector,我注意到所有泄漏都在各種庫的內部,包括CRT,VS庫和boost。
例如,這裏的第3所泄漏的調用棧(該項目是一個boost ::測試項目):
---------- 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 [email protected]!. \.......
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 ........ ........
有誰知道這是怎麼回事?
編輯:
從我明白,所述2個開關/模式之間的差別是兩個連接的DLL是否將共享相同的CRT(例如,存儲器管理)或每一個具有它自己的。當每個使用自己的(/ MT [d])時,則不能釋放由另一個分配的資源。
但是,我將所有內容靜態鏈接起來,因此沒有涉及任何DLL,至少在我的代碼中沒有。