download file memory usage
-
I am writing a program that downloads a database on remote laptops, When downloading the file I noticed that my program uses about 15 MB of memory and calls Windows Explorer and WE uses about 16 MB of memory, the database file is about 60MB. I was wondering if there is something i am missing to reduce the amount of memory I am using. the laptops that will be using this app are older laptops and I want this process not to interfere with another database app that is very memory intensive. and once the download is complete it does not release the memory to a reasonable level any ideas. Thanks Rob FileStream fs = null; //' To access the local file; WebRequest req; //StreamReader sr; try { // This sets up the Request instance req = WebRequest.Create("http://www.domian.com/file.zip"); // Use a GET since no data is being sent to the web server req.Method = "GET"; // This causes the round-trip WebResponse rsp = req.GetResponse(); try { // Open the file to stream in the content fs = new FileStream("file.zip", FileMode.Create); // Copy the content from the response stream to the file. CopyData(rsp.GetResponseStream(), fs); }
-
I am writing a program that downloads a database on remote laptops, When downloading the file I noticed that my program uses about 15 MB of memory and calls Windows Explorer and WE uses about 16 MB of memory, the database file is about 60MB. I was wondering if there is something i am missing to reduce the amount of memory I am using. the laptops that will be using this app are older laptops and I want this process not to interfere with another database app that is very memory intensive. and once the download is complete it does not release the memory to a reasonable level any ideas. Thanks Rob FileStream fs = null; //' To access the local file; WebRequest req; //StreamReader sr; try { // This sets up the Request instance req = WebRequest.Create("http://www.domian.com/file.zip"); // Use a GET since no data is being sent to the web server req.Method = "GET"; // This causes the round-trip WebResponse rsp = req.GetResponse(); try { // Open the file to stream in the content fs = new FileStream("file.zip", FileMode.Create); // Copy the content from the response stream to the file. CopyData(rsp.GetResponseStream(), fs); }
How exactly are you copying the data from the response stream to the file stream? Another thing to consider is that looking at memory usage in the Task Manager (which is what I assume you are doing) can often be misleading. The allocated memory listed for a .NET-based application often includes memory which has been collected (i.e. released) as far as the application goes, but which simply hasn't been given back to the system by the runtime. However, that memory can be given back if and when the runtime believes the system needs it. If there are specific performance (memory or CPU) requirements for your application, then I would suggest using a profiler to help determine where the bottlenecks are in your application. -Phil