pResult = _malloc_dbg(nSize, nType, lpszFileName, nLine);
pConnection=pSession.GetHttpConnection("127.0.0.1");
提示这两句有泄漏,可是在程序后面我已经加入了pSession.Close()
这种泄漏该怎么解决?
pConnection=pSession.GetHttpConnection("127.0.0.1");
提示这两句有泄漏,可是在程序后面我已经加入了pSession.Close()
这种泄漏该怎么解决?
_free_dbg(lpszFileName,nType);
去释放内存的。
难道mfc这种自带的也没有对内存处理吗?
第二句是在我写的cpp中...
所在的函数整个发出来看看!
{
CString str,szAllData,post,status;
char * postdata,* aim,* flag;
switch (conn_type)
{
case 0:
post="logintype=3F";
aim="/php/logout_offnet?quick=yes";
break;
case 1:
post="logintype=C1";
aim="/php/login_net?mode=2&quick=yes&refer=1";
break;
case 2:
post="logintype=B2";
aim="/php/onlinestatus.php";
break;
case 3:
post="logintype=E9";
aim="/php/onlinestatus.php";
break;
default:
return false;
}
postdata=post.GetBuffer(post.GetLength());
CHttpConnection *pConnection;
CInternetSession pSession(NULL,1,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
CHttpFile *pHttpFile;
pConnection=pSession.GetHttpConnection("127.0.0.1");
pHttpFile=pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST,"/php/user_login.php",NULL,1,NULL,NULL,INTERNET_FLAG_EXISTING_CONNECT);
pHttpFile->AddRequestHeaders("Accept: */*");
pHttpFile->AddRequestHeaders("Content-Type: application/x-www-form-urlencoded");
pHttpFile->SendRequest(NULL,0,(LPVOID)postdata,strlen(postdata));
pHttpFile=pConnection->OpenRequest(NULL,aim,NULL,1,NULL,NULL,INTERNET_FLAG_EXISTING_CONNECT);
pHttpFile->SendRequest();
while(pHttpFile->ReadString(str))
{
str.TrimLeft();
str.TrimRight();
szAllData+=str;
}
if(conn_type<2)
{
int succ=szAllData.Find("bbbbbbb");
if(succ>0)
MessageBox(flag);
m_statusint=conn_type;
SetStatus();
}
if(conn_type==2)
{
int succ=szAllData.Find"aaaaaaaa");
if(succ>0)
return false;
else
return true;
}
if(conn_type==3)
{
int succ=szAllData.Find("xadfasdfa");
if(succ>0)
{
m_statusint=1;
SetStatus();
}
else
{
m_statusint=0;
SetStatus();
}
}
pHttpFile->Close();
pConnection->Close();
pSession.Close();
return true;
}
pConnection.Close();
delete pConnection;
需要对post调用 ReleaseBuffer ()
现在变成这句话有内存泄漏,其他的内存泄漏是在MFC所自带的cpp中
类似于afxmem.cpp
pResult = _malloc_dbg(nSize, nType, lpszFileName, nLine);
这句话也泄漏... :(
szAllData.ReleaseBuffer();
delete pHttpFile;
delete pConnection;
delete pSession;
在源程序最后都加上了这个,出现以上问题...