title: Serializing a large object in JSON with asp net core
body: <p>My API is a .Net Core 3.1 and I have an object that can be very large depending on the query filters.
  The overall time is very fast (about 10 seconds for a 100k rows), but when I send it back to the client, it takes +- 2 minutes.</p>
  
  <p>To return the object, I just return with the Ok method like below:</p>
  
  <pre><code>return Ok(object);
  </code></pre>
  
  <p>If I try to serialize this object and send the JSON as content, it's fast but I start to get out of memory exception with multiple calls because the memory is not released.</p>
  
  <pre><code>var json = JsonConvert.SerializeObject(object);
  return Content(json);
  </code></pre>
  
  <p>I'm using Newtonsoft.Json, but I have tried the new System.Text.Json too.</p>
  
  <p>Is there any other approach to work with large objects and serialization, or somehow work with the Garbage Collector to release the allocated memory?</p>