From: Larry on 5 Nov 2007 11:19 I'm trying to use CFtpConnection GetFile to download files from a WS_FTP server. I found if I download 1000 files (Size from 17KB to 25KB ), it can cause about 10M memory leaking. When I commented out the GetFile( ) line, there was no memorry leaking. WHY? Following is part of my source code: try { // Request a connection to Image Server //Use default FTP Port //Use Passive MODE pConnect = sess.GetFtpConnection(strISIP,strFtpUser,strFtpPwd,INTERNET_INVALID_PORT_NUMBER,TRUE); //Change FTP folder pConnect->SetCurrentDirectory(_T("/Transfer")); // use a file find object to enumerate files CFtpFileFind finder(pConnect); // start looping BOOL bFoundFile = finder.FindFile(_T("*.pgp")); while ((bFoundFile==TRUE)&&(nMaxImages<MAX_IMAGE_NUM)) { bFoundFile = finder.FindNextFile(); strRemoteName=finder.GetFileName(); strLocalName=strLocalPath+strRemoteName; // BOOL bFailIfExists = FALSE, //DWORD dwAttributes = FILE_ATTRIBUTE_NORMAL, // DWORD dwFlags = FTP_TRANSFER_TYPE_BINARY, // DWORD_PTR dwContext = 1 bGetFile=pConnect- >GetFile(strRemoteName,strLocalName,FALSE,FILE_ATTRIBUTE_NORMAL,FTP_TRANSFER_TYPE_BINARY, 1); If get File Remove the file; if(bGetFile==TRUE) { pConnect->Remove(strRemoteName); } nMaxImages++; } } catch (CInternetException* pEx) { TCHAR sz[1024]; pEx->GetErrorMessage(sz, 1024); pEx->Delete(); } // if the connection is open, close it if (pConnect != NULL) { pConnect->Close(); delete pConnect; }
From: Mark Salsbery [MVP] on 5 Nov 2007 13:43 How are you detecting the memory leak? The calls you make get passed by MFC directly to WinInet functions, so if there's a leak, it's in there somewhere :) Mark -- Mark Salsbery Microsoft MVP - Visual C++ "Larry" <changquansheng(a)gmail.com> wrote in message news:1194279583.844637.130990(a)k35g2000prh.googlegroups.com... > I'm trying to use CFtpConnection GetFile to download files from a > WS_FTP server. I found if I download 1000 files (Size from 17KB to > 25KB ), it can cause about 10M memory leaking. When I commented out > the GetFile( ) line, there was no memorry leaking. WHY? > > Following is part of my source code: > > > > > try > { > // Request a connection to Image Server > //Use default FTP Port > //Use Passive MODE > pConnect = > sess.GetFtpConnection(strISIP,strFtpUser,strFtpPwd,INTERNET_INVALID_PORT_NUMBER,TRUE); > > //Change FTP folder > pConnect->SetCurrentDirectory(_T("/Transfer")); > > // use a file find object to enumerate files > CFtpFileFind finder(pConnect); > > // start looping > BOOL bFoundFile = finder.FindFile(_T("*.pgp")); > > while ((bFoundFile==TRUE)&&(nMaxImages<MAX_IMAGE_NUM)) > { > bFoundFile = finder.FindNextFile(); > strRemoteName=finder.GetFileName(); > strLocalName=strLocalPath+strRemoteName; > > // BOOL bFailIfExists = FALSE, > //DWORD dwAttributes = FILE_ATTRIBUTE_NORMAL, > // DWORD dwFlags = FTP_TRANSFER_TYPE_BINARY, > // DWORD_PTR dwContext = 1 > > bGetFile=pConnect- >>GetFile(strRemoteName,strLocalName,FALSE,FILE_ATTRIBUTE_NORMAL,FTP_TRANSFER_TYPE_BINARY, > 1); > > If get File Remove the file; > if(bGetFile==TRUE) > { > pConnect->Remove(strRemoteName); > > } > > > > nMaxImages++; > > } > } > catch (CInternetException* pEx) > { > TCHAR sz[1024]; > pEx->GetErrorMessage(sz, 1024); > pEx->Delete(); > } > > // if the connection is open, close it > if (pConnect != NULL) > { > pConnect->Close(); > delete pConnect; > } >
From: Larry on 6 Nov 2007 09:38 Hello Mark, Thank you very much for the reply. I used Performance Monitor in Task Manager. I found the program uses more and more memory, it increases slowly. but available physical memory going down much faster. I also noticed explorer.exe use more and more memory and a lot od page falut. After I downloaded about 200,000 small files size from (17KB to 25KB) , explorer.exe used 89MB memory and more than 200,000 page faults. I don't think it the CFtpconnection->GetFile problem but something related to it. Laurence
From: Mark Salsbery [MVP] on 6 Nov 2007 11:49 You may want to read articles similar to this: http://technet.microsoft.com/en-us/library/Bb742598.aspx It's tough to use perf monitor/task manager as a leak detector since the OS is trying to efficiently handle memory in the background. For example, memory is often not completely released unless it's needed elsewhere - that way when an app needs a block of memory again, it's can be obtained faster. Mark -- Mark Salsbery Microsoft MVP - Visual C++ "Larry" <changquansheng(a)gmail.com> wrote in message news:1194359904.957314.108780(a)k79g2000hse.googlegroups.com... > Hello Mark, > > Thank you very much for the reply. > > I used Performance Monitor in Task Manager. I found the program uses > more and more memory, it increases slowly. but available physical > memory going down much faster. I also noticed explorer.exe use more > and more memory and a lot od page falut. After I downloaded about > 200,000 small files size from (17KB to 25KB) , explorer.exe used 89MB > memory and more than 200,000 page faults. I don't think it the > CFtpconnection->GetFile problem but something related to it. > > Laurence >
|
Pages: 1 Prev: Volume Shadow Copy - BackupComplete and VSS_E_BAD_STATE Next: Module definition file |