各位高手请指点一下啊!!谢谢!

huazaimh 2004-12-22 06:00:56
多线程的问题
老是出现内存溢出,不知道是什么原因,请指点!!!谢谢!
void CVideoforward::InitSenders()
{
int i;
for(i=0;i<MAXSENDERNUM;i++)
{
this->G_Senders[i].used=0;
this->G_Senders[i].count=0;
this->G_Senders[i].front=0;
this->G_Senders[i].rear=0;
this->G_Senders[i].sendfd=-1;
InitializeCriticalSection(&(this->G_Senders[i].Cs_buf));
InitializeCriticalSection(&(this->G_Senders[i].Cs_count));
ZeroMemory(this->G_Senders[i].remoteip,20);
ZeroMemory(this->G_Senders[i].multicastip,20);
// _beginthread((void (__cdecl *)(void *))VideoSendFun,0,(void*)i);
if(pVideoSendFunThread[i])
TerminateThread(pVideoSendFunThread[i],0);
else
pVideoSendFunThread[i] = CreateThread(NULL,
0,
(LPTHREAD_START_ROUTINE)VideoSendFun,
NULL);
} this,
0,

}
...全文
68 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
MuseIn 2004-12-23
  • 打赏
  • 举报
回复
_endthread
BigFanOfCpp 2004-12-23
  • 打赏
  • 举报
回复
建议_beginthread和_endthread配套调用,不能用TerminateThread(...).
huazaimh 2004-12-23
  • 打赏
  • 举报
回复
谢谢大伙!!!
oyljerry 2004-12-23
  • 打赏
  • 举报
回复
_endthread
TerminateThread注意资源释放
HunterForPig 2004-12-22
  • 打赏
  • 举报
回复
建议用endthread
xenke 2004-12-22
  • 打赏
  • 举报
回复
用_endthread配对使用_beginthread
Hendy_So 2004-12-22
  • 打赏
  • 举报
回复
最好不要用TerminateThread结束线程,让线程主动退出吧。
Kudeet 2004-12-22
  • 打赏
  • 举报
回复
是不是TerminateThread结束掉的那个线程里引起的。看看里面是不是有资源没有释放

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧