Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Big download causes memory exception
Message
De
09/07/2010 02:23:16
 
 
À
09/07/2010 01:14:39
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:
01471961
Vues:
42
>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?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform