ASP.NET main memory issue

I have a basic ASP.NET application that uses mongo DB with terabytes of data. Sometimes requests require quite a lot of memory. The problem is that even though the process has ended, the memory is not freed. The amount of memory used grows with each request. I have reproduced this situation in a very simple code below. Also included is a screenshot of the diagnostic tools.

[Route("api/[controller]")]
public class ValuesController : Controller
{
    [HttpGet]
    public IEnumerable<string> Get()
    {
        List<string> result = new List<string>();

        for (var i = 0; i < 5000000; ++i)
        {
            result.Add(Guid.NewGuid().ToString());
        }

        var a = result.Take(100).ToList();
        return a;
    }

}

      

enter image description here

+3


source to share





All Articles