2013-01-09 32 views
4
#define _CRTDBG_MAP_ALLOC 
#include <stdlib.h> 
#include <crtdbg.h> 
#include <thread> 

using namespace std; 

void Hello() 
{} 

int main() 
{ 
    { 
     std::thread(Hello).join(); 
    }  

    _CrtDumpMemoryLeaks(); 
} 

輸出窗口顯示:(VC++編譯器版本:2012年11月CTP)這是微軟執行std :: thread的一個大錯誤嗎?

The thread 0x5ab8 has exited with code 0 (0x0). 
Detected memory leaks! 
Dumping objects -> 
{261} normal block at 0x002A2E00, 44 bytes long. 
Data: <    > 01 00 00 00 00 00 00 00 00 00 00 00 0A 00 00 00 
Object dump complete. 
The thread 0x5abc has exited with code 0 (0x0). 
The thread 0x5ab4 has exited with code 0 (0x0). 
The program '[0x5A94] C++11.exe' has exited with code 0 (0x0). 
+3

讓這一個for循環並看看泄漏是否增長。它可能是一些懶惰的初始化數據結構,它們只被初始化一次,似乎是「泄漏」的。 –

+8

也許這可能有所幫助:http://connect.microsoft.com/VisualStudio/feedback/details/757212/vs-2012-rc-std-thread-reports-memory-leak-even-on-stack? – Carsten

+0

@Aschratt你應該把這個評論變成一個答案。 – Gorpik

回答

相關問題