Manoj S  Pant

Manoj S Pant

  • NA
  • 1k
  • 1.1m

release memory from BinaryReader

Nov 28 2016 12:11 PM
 
 
Using fs As System.IO.FileStream = New FileStream(p_strPath, FileMode.Open, FileAccess.Read)
   Using br As BinaryReader = New BinaryReader(fs)
         
          br.ReadBytes(fs.Length)   // here memory hold for file, need to free this free .
End Using
    End Using
 
 
In above code when binary reader  read bytes from file stream, it allocate the memory of file size into RAM,  and this memory still  block even after completion of this function, how can we release this memory, I am checking this memory from task manager.
 
Example :
Suppose my application consuming 80 MB size and when attached file of 100 MB then  on br.ReadBytes(fs.Length), total memory consume by application is 80 + 100 = 180 MB.
but problem is that, 100 MB memory is not released even after completion of above function.
 
Question: How to release this 100 MB from application after completion of this function.
 
 

Answers (1)