Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Big download causes memory exception
Message
De
09/07/2010 02:39:35
 
 
À
09/07/2010 02:23:16
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01471918
Message ID:
01471964
Vues:
38
>>I see two problems .
>>(1) As you say, you keep all of the 2.2 GB in a memory stream
>>(2) On top of that, you create another array of 2.2 GB and passing that to the FileStream
>>
>>The solution that does not take extra memory is to write loBuffer to a FileStream directly ( as opposed to loMemoryStream)
>>
>>Update: I do not see what the size of loBuffer is - but 4Kb to 16Kb is sufficient
>>
>>Update 2: using passive mode is not a bad idea
>>
>>                ' FTP setup
>>>                loFtpWebRequest = System.Net.FtpWebRequest.Create(New Uri(lcURI))
>>>                loFtpWebRequest.Credentials = New System.Net.NetworkCredential(cUsername, cPassword)
>>>                loFtpWebRequest.Method = System.Net.WebRequestMethods.Ftp.DownloadFile
>>>                loFtpWebRequest.UseBinary = True
>>                 loFtpWebRequest.UsePassive= True
>>
>>
>>
>
>Thanks, this has been a very productive day. This is also a very good answer.
>
>nBuffer was 1024. I have increased it to 4096 as suggested. I do not see any difference in speed. What is advantage of using a higher buffer? If it creates less data manipulations between the client and the server, than this is good.
>
>I adjusted the method to dump into loFileStream as suggested. This has resolved both situations. It also makes the code much simpler. The file is created as is without any additional manipulation.
>
>What is the use of UsePassive BTW?

It means that the remote site cannot open a connection, it tells you which port it will use and you open the port - necessary if you use a FireWall

excerpt from http://en.wikipedia.org/wiki/File_Transfer_Protocol


FTP can be run in active mode or passive mode, which control how the second connection is opened. In active mode the client sends the server the IP address port number that the client will use for the data connection, and the server opens the connection. Passive mode was devised for use where the client is behind a firewall and unable to accept incoming TCP connections. The server sends the client an IP address and port number and the client opens the connection to the server.[3] Both modes were updated in September 1998 to add support for IPv6 and made some other changes to passive mode, making it extended passive mode[5].


And also

http://slacksite.com/other/ftp.html
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform