为什么这样一个while会出现内存问题呢。。。
这是一个检索网络活动主机的程序:
while(ntohl(startip)<=ntohl(endip))//起始IP<结束IP { if(threadnumcounter>threadnumlimit)//线程数量超过限制数量(我设的是20) { Sleep(1000); continue; } sockaddr_in * pipaddrtemp=new(sockaddr_in); if(!pipaddrtemp) { cout<<"memory alloc failed"<<endl; return; } *pipaddrtemp=dest; //创建新线程 hthread=CreateThread(NULL,NULL,FindIp,(LPVOID)pipaddrtemp,NULL,NULL);//创建线程发送接收ICMP包 CloseHandle(hthread); startip=htonl(ntohl(startip)+1);//IP加1 dest.sin_addr.s_addr=startip; }