MVC ASP.NET is using a lot of memory

前端 未结 6 2086
谎友^
谎友^ 2021-02-14 09:53

If I just browse some pages on the app, it sits at around 500MB. Many of these pages access the database but at this point in time, I only have roughly a couple of rows each for

6条回答
  •  北海茫月
    2021-02-14 10:27

    This could be one of a few things:

    As your file is rather large and is stored in your database and you are getting it via Entity Framework, you are caching this data in a few places. Each EF request caches that data until your context is disposed. When you return the file from the action, the data is then loaded again and then streamed to the client. All of this happens in ASP .NET as explained already.

    A solution to this issue to not to stream large files directly from the database with EF and ASP .NET. A better solution is to use a background process to cache large files locally to the website and then have the client download them with a direct URL. This allows IIS to manage the streaming, saves your website a request and saves a lot of memory.

    OR (less likely)

    Seeing that you are using Visual Studio 2013, this sounds awfully like a Page Inspector issue.

    What happens is when you run your website with IIS Express from Visual Studio, Page Inspector caches all of the response data - including that of your file - causing a lot of memory to be used. Try adding:

    
        
    
    

    to your web.config to disable Page Inspector to see if that helps.

    TL;DR

    Cache the large file locally and let the client download the file directly. Let IIS handle the hard work for you.

提交回复
热议问题