WebClient and WebResponse eats up memory

S

ScottO

How can I upload a file to a ASP.NET page without having the stream eating
up memory without using a 3rd party component?

How can I download a file from a different webpage without eating up memory
without using a 3rd party component?

Files that are just under 2 Gig.

Using FTP is not an option.

Using WebClient.DownloadData and WebResponse.GetResponseStream appear to
both eat up CPU and memory.

Thanks in advanced for the advice,

Scott
 
N

Nicholas Paldino [.NET/C# MVP]

ScottO,

To upload and download the file, you should be using HttpWebRequest and
HttpWebResponse. Both of them use a stream to get the data to/from the
server, which should reduce the overall working set that you would use. If
you use WebClient, it is going to return everything in an array at one time,
and for large files, like you have noticed, it can be a real
performance-killer.

You should use GetResponseStream, and read in chunks from the stream,
processing them as you read them.

Hope this helps.
 
S

ScottO

Many thanks Nicholas. I will try it and let you know how it turns out...

Nicholas Paldino said:
ScottO,

To upload and download the file, you should be using HttpWebRequest and
HttpWebResponse. Both of them use a stream to get the data to/from the
server, which should reduce the overall working set that you would use. If
you use WebClient, it is going to return everything in an array at one time,
and for large files, like you have noticed, it can be a real
performance-killer.

You should use GetResponseStream, and read in chunks from the stream,
processing them as you read them.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

ScottO said:
How can I upload a file to a ASP.NET page without having the stream eating
up memory without using a 3rd party component?

How can I download a file from a different webpage without eating up memory
without using a 3rd party component?

Files that are just under 2 Gig.

Using FTP is not an option.

Using WebClient.DownloadData and WebResponse.GetResponseStream appear to
both eat up CPU and memory.

Thanks in advanced for the advice,

Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top