C++程序卡死的幾種原因

1.很常見的原因:for while 死循環;

for(;;);

while(true);

while(1);

2.遞歸調用死循環;

3.對帶有STL類對象的變量進行memset/ZeroMemory,比如vector/map/list,可能出現DEBUG環境下正常運行(DEBUG環境對某些操作進行了優化),RELEASE環境則莫名其妙線程卡死;

struct tagTest{
    int nCount;
    std::vector<char> vData;
}

tagTest t1;
ZeroMemory(&t1,sizeof(t1))

4.線程死鎖; 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章