I had this same problem a while back. I was reading in a 100MB+ file in a program. I found that I had to call outside of the function that actually used the ram. It doesn't want to release it within the same function.
-----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of dave wanta Sent: Friday, February 03, 2006 2:47 PM To: [email protected] Subject: [ADVANCED-DOTNET] releasing memory Hi All, I'm trying to get my app to release some memory, as it can grow quite large, and throw an OutOfMemory exception. Here is a test example, the code is pretty small, but I'm reading a 35meg file. Here's what the code looks like: byte[] data = ReadFile( ...); //memory footprint is about 42megs (taskman), which is acceptable chars = Encoding.ASCII.GetChars( data ); //jumps to 115meg --varies a few meg depending upon the Encoding used. data = null; //still stays at 115meg GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); //memory is still at 115 meg. Is there any reason why the memory wouldn't have been released after calling GC.Collect()? I'm assuming calling GC.Collect() would have released the memory used by data. Thoughts? Comments? Thanks, Dave =================================== This list is hosted by DevelopMentorR http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com
