Intel Inspector сообщает об утечке внутренней памяти даже из самых простых примеров std :: mutex:
// std_mutex_test.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"#include <iostream>
#include "TestMutex.h"
int _tmain(int argc, _TCHAR* argv[])
{
std::cout << "Starting\n";
CTestMutex testMutex;
for (int i = 0; i < 10; i++)
testMutex.DoStuff();
std::cout << "Done\nPress a key...\n";
getchar();
return 0;
}
// TestMutex.h : Class for testing mutex
//
#include "stdafx.h"#include "TestMutex.h"
class CTestMutex
{
private:
std::mutex mtx1;
long sharedStuff; // Example is just for testing the mutex, otherwise I would use atomic here
public:
CTestMutex() { sharedStuff = 0; }
~CTestMutex();
void CTestMutex::DoStuff()
{
mtx1.lock();
sharedStuff++;
mtx1.unlock();
}
};
Отчет Intel Inspector XE 2013 выглядит следующим образом:
ID Type Sources Modules Object Size State
P1 Kernel resource leak schedulerbase.cpp std_mutex_test.exe New
P2 Memory leak cachelocalschedulegroup.h std_mutex_test.exe 304 New
P3 Memory leak collections.h std_mutex_test.exe 7168 New
P4 Memory leak collections.h std_mutex_test.exe 84 New
P5 Memory leak collections.h std_mutex_test.exe 14336 New
P6 Memory leak collections.h std_mutex_test.exe 4 New
P7 Memory leak collections.h std_mutex_test.exe 56 New
P8 Memory leak collections.h std_mutex_test.exe 12 New
P9 Memory leak collections.h std_mutex_test.exe 96 New
P10 Memory leak collections.h std_mutex_test.exe 49192 New
P11 Memory leak collections.h std_mutex_test.exe 288 New
P12 Memory leak contextbase.h std_mutex_test.exe 16 New
P13 Memory leak externalcontextbase.cpp std_mutex_test.exe 28 New
P14 Memory leak mailbox.h std_mutex_test.exe 44 New
P15 Memory leak mailbox.h std_mutex_test.exe 256 New
P16 Memory leak resourcemanager.cpp std_mutex_test.exe 12 New
P17 Memory leak resourcemanager.cpp std_mutex_test.exe 44 New
P18 Memory leak resourcemanager.cpp std_mutex_test.exe 52 New
P19 Memory leak resourcemanager.cpp std_mutex_test.exe 416 New
P20 Memory leak resourcemanager.cpp std_mutex_test.exe 208 New
P21 Memory leak resourcemanager.cpp std_mutex_test.exe 144 New
P22 Memory leak resourcemanager.cpp std_mutex_test.exe 64 New
P23 Memory leak rminternal.h std_mutex_test.exe 64 New
P24 Memory leak rminternal.h std_mutex_test.exe 8 New
P25 Memory leak rminternal.h std_mutex_test.exe 292 New
P26 Memory leak schedulerbase.cpp std_mutex_test.exe 176 New
P27 Memory leak schedulerbase.cpp std_mutex_test.exe 56 New
P28 Memory leak schedulerbase.cpp std_mutex_test.exe 20 New
P29 Memory leak schedulerbase.cpp std_mutex_test.exe 4 New
P30 Memory leak schedulerbase.cpp std_mutex_test.exe 4 New
P31 Memory leak schedulerbase.cpp std_mutex_test.exe 192 New
P32 Memory leak schedulerbase.cpp std_mutex_test.exe 136 New
P33 Memory leak schedulerbase.cpp std_mutex_test.exe 1024 New
P34 Memory leak schedulerpolicybase.cpp std_mutex_test.exe 40 New
P35 Memory leak schedulerproxy.cpp std_mutex_test.exe 2104 New
P36 Memory leak schedulerproxy.cpp std_mutex_test.exe 4 New
P37 Memory leak schedulerproxy.cpp std_mutex_test.exe 704 New
P38 Memory leak structuredworkstealingqueue.h std_mutex_test.exe 2048 New
P39 Memory leak structuredworkstealingqueue.h std_mutex_test.exe 4096 New
P40 Memory leak threadscheduler.cpp std_mutex_test.exe 520 New
P41 Memory leak threadscheduler.cpp std_mutex_test.exe 1664 New
P42 Memory not deallocated trace.cpp std_mutex_test.exe 24 New
Есть ли что-то, что я делаю не так, или это известно ядро утечки внутренней памяти, которые я не могу контролировать?
Скомпилировал пример, используя компилятор Intel C ++ с использованием многопоточного флага отладки / MTd, с запуском Visual Studio 2012 Update 3 в Windows 7 со всеми последними обновлениями.
std::lock_guard
также утечки памяти:
void CTestMutex::DoStuff()
{
std::lock_guard<std::mutex> lock(mtx1);
sharedStuff++;
}
Intel Inspector XE 2013 std::lock_guard
доклад:
ID Type Sources Modules Object Size State
P1 Kernel resource leak schedulerbase.cpp std_mutex_test.exe Not fixed
P2 Memory leak cachelocalschedulegroup.h std_mutex_test.exe 304 Not fixed
P3 Memory leak collections.h std_mutex_test.exe 7168 Not fixed
P4 Memory leak collections.h std_mutex_test.exe 84 Not fixed
P5 Memory leak collections.h std_mutex_test.exe 14336 Not fixed
P6 Memory leak collections.h std_mutex_test.exe 4 Not fixed
P7 Memory leak collections.h std_mutex_test.exe 56 Not fixed
P8 Memory leak collections.h std_mutex_test.exe 12 Not fixed
P9 Memory leak collections.h std_mutex_test.exe 96 Not fixed
P10 Memory leak collections.h std_mutex_test.exe 49192 Not fixed
P11 Memory leak collections.h std_mutex_test.exe 288 Not fixed
P12 Memory leak contextbase.h std_mutex_test.exe 16 Not fixed
P13 Memory leak externalcontextbase.cpp std_mutex_test.exe 28 Not fixed
P14 Memory leak mailbox.h std_mutex_test.exe 44 Not fixed
P15 Memory leak mailbox.h std_mutex_test.exe 256 Not fixed
P16 Memory leak resourcemanager.cpp std_mutex_test.exe 12 Not fixed
P17 Memory leak resourcemanager.cpp std_mutex_test.exe 44 Not fixed
P18 Memory leak resourcemanager.cpp std_mutex_test.exe 52 Not fixed
P19 Memory leak resourcemanager.cpp std_mutex_test.exe 416 Not fixed
P20 Memory leak resourcemanager.cpp std_mutex_test.exe 208 Not fixed
P21 Memory leak resourcemanager.cpp std_mutex_test.exe 144 Not fixed
P22 Memory leak resourcemanager.cpp std_mutex_test.exe 64 Not fixed
P23 Memory leak rminternal.h std_mutex_test.exe 64 Not fixed
P24 Memory leak rminternal.h std_mutex_test.exe 8 Not fixed
P25 Memory leak rminternal.h std_mutex_test.exe 292 Not fixed
P26 Memory leak schedulerbase.cpp std_mutex_test.exe 176 Not fixed
P27 Memory leak schedulerbase.cpp std_mutex_test.exe 56 Not fixed
P28 Memory leak schedulerbase.cpp std_mutex_test.exe 20 Not fixed
P29 Memory leak schedulerbase.cpp std_mutex_test.exe 4 Not fixed
P30 Memory leak schedulerbase.cpp std_mutex_test.exe 4 Not fixed
P31 Memory leak schedulerbase.cpp std_mutex_test.exe 192 Not fixed
P32 Memory leak schedulerbase.cpp std_mutex_test.exe 136 Not fixed
P33 Memory leak schedulerbase.cpp std_mutex_test.exe 1024 Not fixed
P34 Memory leak schedulerpolicybase.cpp std_mutex_test.exe 40 Not fixed
P35 Memory leak schedulerproxy.cpp std_mutex_test.exe 2104 Not fixed
P36 Memory leak schedulerproxy.cpp std_mutex_test.exe 4 Not fixed
P37 Memory leak schedulerproxy.cpp std_mutex_test.exe 704 Not fixed
P38 Memory leak structuredworkstealingqueue.h std_mutex_test.exe 2048 Not fixed
P39 Memory leak structuredworkstealingqueue.h std_mutex_test.exe 4096 Not fixed
P40 Memory leak threadscheduler.cpp std_mutex_test.exe 520 Not fixed
P41 Memory leak threadscheduler.cpp std_mutex_test.exe 1664 Not fixed
P42 Memory not deallocated trace.cpp std_mutex_test.exe 24 Not fixed
Задача ещё не решена.
Других решений пока нет …