malhenry
2006-03-17 21:40:27 UTC
I am using a 3rd party tool that claims the following line is the source of a
memory leak:
CInternetSession session("xxx");
Perhaps I am not cleaning up properly?
Here are the main lines of my code with error checking removed:
CFtpConnection fcTraffic = NULL:
fcTraffic = session.GetFtpConnection((LPCTSTR)FtpSettings.FTPSiteAddress,
(LPCTSTR)FtpSettings.FTPUserName, (LPCTSTR)FtpSettings.FTPPassword);
Succeed = fcTraffic->SetCurrentDirectory(csPath);
Succeed = fcTraffic->PutFile(csLocal, csTempFile, FTP_TRANSFER_TYPE_BINARY );
Succeed = fcTraffic->Remove(csFile);
Succeed = fcTraffic->Rename(csTempFile, csFile);
if (fcTraffic)
fcTraffic->Close();
delete fcTraffic;
fcTraffic = NULL;
session.Close();
delete session;
I suspect that I am not cleaning up session properly. The third party tool
does not say fcTraffic is a leak and when I step thru in the debugger, after
I delete fcTraffic, the debugger says error: expression cannot be evaluated
when I try to look at fctraffic.
However, after I delete session and look at it in the debugger I can still
see some values in the object.
Any ideas on what I am doing wrong?
Thanks!
memory leak:
CInternetSession session("xxx");
Perhaps I am not cleaning up properly?
Here are the main lines of my code with error checking removed:
CFtpConnection fcTraffic = NULL:
fcTraffic = session.GetFtpConnection((LPCTSTR)FtpSettings.FTPSiteAddress,
(LPCTSTR)FtpSettings.FTPUserName, (LPCTSTR)FtpSettings.FTPPassword);
Succeed = fcTraffic->SetCurrentDirectory(csPath);
Succeed = fcTraffic->PutFile(csLocal, csTempFile, FTP_TRANSFER_TYPE_BINARY );
Succeed = fcTraffic->Remove(csFile);
Succeed = fcTraffic->Rename(csTempFile, csFile);
if (fcTraffic)
fcTraffic->Close();
delete fcTraffic;
fcTraffic = NULL;
session.Close();
delete session;
I suspect that I am not cleaning up session properly. The third party tool
does not say fcTraffic is a leak and when I step thru in the debugger, after
I delete fcTraffic, the debugger says error: expression cannot be evaluated
when I try to look at fctraffic.
However, after I delete session and look at it in the debugger I can still
see some values in the object.
Any ideas on what I am doing wrong?
Thanks!