If you're using version 1.0 of the framework, the problem is likely a bug where 
objects don't get properly released from memory if they're on the Large Object 
Heap.  I believe that large strings would fall into that category.  I 
personally know of no work around other than an upgrade.
 
Mitch Gordon
[EMAIL PROTECTED]
http://www.enterpriseetc.com


----- Original Message ----
From: dave wanta <[EMAIL PROTECTED]>
To: [email protected]
Sent: Friday, February 03, 2006 3:47:17 PM
Subject: 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 DevelopMentor®  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

Reply via email to