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.线程死锁; 

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