Ftp连接正常时,CInternetException造成内存泄露

jinlsg 2009-03-15 04:47:43
错误提示是这样的:
Detected memory leaks!
Dumping objects ->
inet.cpp(2746) : {667} client block at 0x003D7A00, subtype 0, 20 bytes long.
a CInternetException object at $003D7A00, 20 bytes long
inet.cpp(2746) : {521} client block at 0x003D79A8, subtype 0, 20 bytes long.
a CInternetException object at $003D79A8, 20 bytes long
inet.cpp(2746) : {375} client block at 0x003D78D8, subtype 0, 20 bytes long.
a CInternetException object at $003D78D8, 20 bytes long
Object dump complete.
The thread 0xC80 has exited with code 0 (0x0).

软件代码如下:
BOOL CFtp::ConnectServer(CString sFtpServerName, CString sFtpUser, CString sFtpPassword, CString& sError)
{
if(m_pFinder)
{
m_pFinder->Close();
delete m_pFinder;
m_pFinder = NULL;
}
if(m_pFtp)
{
m_pFtp->Close();
delete m_pFtp;
m_pFtp = NULL;
}
try
{
m_pFtp = m_Session.GetFtpConnection(sFtpServerName, sFtpUser, sFtpPassword);
}
catch(CInternetException *pex) //内存泄露
{
TCHAR szErr[1024];
pex->GetErrorMessage(szErr, 1024);
sError = szErr;
pex->Delete();
pex=NULL;
return FALSE;
}
m_pFinder = new CFtpFileFind(m_pFtp);
m_sFtpServerName = sFtpServerName;
m_sFtpUser = sFtpUser;
m_sFtpPassword = sFtpPassword;
return TRUE;
}

跟踪发现,当ftp连接正常后,CInternetException 对象也被构造出来了,造成内存泄露.不知道怎么会产生这个问题,请高手指点!
...全文
364 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
jinlsg 2009-03-15
  • 打赏
  • 举报
回复
找到原因了,是自己调用失误造成了,我在别的地方又使用了一个ftp连接,抛出了异常后没有释放CInternetException 对象.

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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