Newsgroups : Microsoft : microsoft.public.inetsdk.programming.wininet : 2006 Mar : Memory Leak with CInternetSession?

www.cryer.info
Managed Newsgroup Archive

Memory Leak with CInternetSession?

Subject:Memory Leak with CInternetSession?
Posted by:"malhenry" (malhen..@discussions.microsoft.com)
Date:Fri, 17 Mar 2006 13:40:27

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!

Replies:

www.cryer.info
Managed Newsgroup Archive