title: Why string is not disposed and how can I optimize the memory usage?
body: <p>I am writing an excel parse web api that reads a structured file into objects(a recurrence function).</p>
  
  <p>But I've noticed a significant memory spike while parsing some files and thus would throw OutOfMemory exception. The excel parse engine needs the whole file to be loaded before it can read its structure. And I found out it's not the loading that consumes the most of the memory, it's the parsing(turning excel to structured objects) and the json http return(serialize the objects to json) that finally kills the memory. For example, a 1M large file can parse into 70M json.</p>
  
  <p>So I googled around, found this .net Memory Profiler and tried to analyze what was going on that led to this huge memory usage. Here is the snapshot that I captured while parsing the same file twice. I've noticed that there are huge string /Object[] that are not being GCed. </p>
  
  <p>Now I'm at lost. What are the best practices when you are dealing with lots of List and lots of string? As to reducing the memory usage, where should I start looking into? What are the best practices while handling long running process(Adding queue? Use signalR to notify the process result?)?</p>
  
  <p>Some guidance would be really appreciated!</p>
  
  <p><a href="https://i.stack.imgur.com/Cwr3V.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Cwr3V.png" alt="enter image description here"></a></p>