分配的内存不可用?真是晕死!
char* pBuf=(char*)malloc(200*1024);
if(pBuf==NULL) { printf("Memory malloc error !\n");
else {
if(recv(sock,pBuf,100*1024,0)<=0) printf("Read error. errno=%d\n",errno); // 条件成立,errno=EFAULT 指示接收缓冲区指针超出程序地址空间
// 如果没有上行的调用,直接进行下行的调用也导致程序段错误
memset(pBuf,0,200*1024);
......
free(pBuf);
}
分配内存前调用system("free")显示系统总内存为190MB,当前可用内存为15MB,SWAP为506MB,当前可用501MB. 内存分配返回了非空指针,却无法使用,真是晕死了!!!