网络模型服务器端通信程序,启动/停止服务(此时并没有任何数据或者连接进来)会基本上最少8K的内存增长,下附主要代码,求大神

网络模型服务器端通讯程序,启动/停止服务(此时并没有任何数据或者连接进来)会基本上最少8K的内存增长,下附主要代码,求大神
int CInternetServer::InitSocket(unsigned int nSvrPort)
{
//2014.6.5
//2014.6.5

char  errorMsg[100];
char  hostName[100];
char  hostComName[100];
in_addr addr;
hostent *host;
DWORD Ret = 0;
WSADATA wsaData;
if ((Ret = WSAStartup(MAKEWORD(0x02,0x02),&wsaData)) != 0)
{
Ret = WSAGetLastError();
sprintf(errorMsg,"failed with wsastart up with %d",Ret);
return Ret;
}
if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2)//judge the socket version
{
sprintf(errorMsg,"the version is not right !");
return -1;
}
//get the host name
Ret = gethostname(hostName,sizeof(hostName));
if (0 == Ret)
{
host = gethostbyname(hostName);
if(host != NULL)
{
memcpy(hostComName,host->h_name,strlen(host->h_name));
memcpy(&addr,host->h_addr_list[0],sizeof(host->h_addr_list[0]));
m_strServerIp = inet_ntoa(addr);
m_iPort = nSvrPort;
}
else
{
Ret = WSAGetLastError();
sprintf(errorMsg,"failed with gethostip with %d",Ret);
return Ret;
}
}
else
{
Ret = WSAGetLastError();
sprintf(errorMsg,"failed with gethostname with %d",Ret);
return Ret;

}

//create the socket
if (0 == Ret)
{
if((m_listenSocket = WSASocket(AF_INET,SOCK_STREAM,0,NULL,0,WSA_FLAG_OVERLAPPED)) == INVALID_SOCKET)
{
Ret = WSAGetLastError();
sprintf(errorMsg,"WSASocket() failed with error %d",Ret);
return Ret;
}
//////////////////////////////////////////////////////////////////////////
//xaq 2014.6.5

//////////////////////////////////////////////////////////////////////////
}

//bind the socket
if (0 == Ret)
{
sockaddr_in InetAddr;
InetAddr.sin_port = htons(nSvrPort);
InetAddr.sin_family = AF_INET;
InetAddr.sin_addr.S_un.S_addr = htonl(INADDR_ANY);
if (bind(m_listenSocket,(PSOCKADDR)&InetAddr,sizeof(sockaddr_in)) == SOCKET_ERROR)
{
Ret = WSAGetLastError();
printf(errorMsg,"bind() failed with error %d/n", Ret); 
return Ret;
}
//////////////////////////////////////////////////////////////////////////
//xaq 2014.6.5

//////////////////////////////////////////////////////////////////////////


}
//listen the socket
if (listen(m_listenSocket,10) == SOCKET_ERROR)
{
Ret = WSAGetLastError();
printf(errorMsg,"listen() failed with error %d/n", Ret); 
return Ret;
}
//////////////////////////////////////////////////////////////////////////
//xaq 2014.6.5

//////////////////////////////////////////////////////////////////////////

//create the completion port
if (0 == Ret)
{
if (m_hCompletionPort == INVALID_HANDLE_VALUE)
{
if((m_hCompletionPort = ::CreateIoCompletionPort(INVALID_HANDLE_VALUE,NULL,0,0)) == INVALID_HANDLE_VALUE)
{
Ret = WSAGetLastError();
printf(errorMsg,"CreateIoCompletionPort failed with error %d/n", Ret);
return Ret;

}
//////////////////////////////////////////////////////////////////////////
//xaq 2014.6.5

//////////////////////////////////////////////////////////////////////////
}
}
//Create a server worker thread and pass the completion port to the thread
if (0 == Ret)
{
if(!m_bWorkThread)
{
SYSTEM_INFO sysInfo;
::GetSystemInfo(&sysInfo);
for (DWORD i = 0; i < sysInfo.dwNumberOfProcessors * 2 + 2; i++)
{
HANDLE hThread;
DWORD  hThreadId;
hThread = CreateThread(NULL,
0,
ServerThread,
this,
0,
&hThreadId);

if (hThread == NULL)
{
Ret = WSAGetLastError();
printf(errorMsg,"CreateServer Thread failed with error %d/n", Ret);
return Ret;
}
//////////////////////////////////////////////////////////////////////////
//xaq 2014.6.5

CloseHandle(hThread);
}
m_bWorkThread = true;
}
}
//create the linsten thread
if(0 == Ret)
{
DWORD hThreadID;
m_hListenThread = CreateThread(NULL,
0,
ListenThread,
this,
0,
&hThreadID);
if (m_hListenThread == NULL)
{
Ret = WSAGetLastError();
printf(errorMsg,"Createlisten Thread failed with error %d/n", Ret);
return Ret;