Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7535877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:25:11+00:00 2026-05-30T06:25:11+00:00

What is the best way to check memory usage in an ASP.NET MVC3 application?

  • 0

What is the best way to check memory usage in an ASP.NET MVC3 application?

I have been told by my hosting provider to recyle the IIS application pool every so often to improve the speed of the site. Is this what is ‘recommended practice’? Surely I shouldn’t need to restart my application every so often? I’d much rather find out if it is an issue with memory usage in my application and correct it. So any tips & best practices you use would be quite helpful too.

The application is based on ASP.NET MVC3, C# and EF Code First. Any guidance, links appreciated.

EDIT:
I found this page after I posted, which is quite useful. But I’d still like to hear any other views.

ASP.NET MVC and EF Code First Memory Usage

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T06:25:12+00:00Added an answer on May 30, 2026 at 6:25 am

    By default IIS recycles the application pool automatically at an interval (I think is 29 hours or so) but that is surely set by the host, no matter how little or how much memory you’re the process is using. THe recycling trigger can be a time interval or when the process hits a certain memory usage limit. I’m sure any shared host has both of them set.

    About memory usage, you can use the GC.GetTotalMemory method which will give you an approximate usage. Even when using Perfmon the readings aren’t very accurate but it gives you an idea.

    //global.asax.cs
     void Application_EndRequest(object o,EventArgs a)
     {
       var ctype=Context.Response.Headers["Content-Type"];
       if (ctype == null || !ctype.Contains("text/html")) return;  
       Context.Response.Write(string.format("<p>Memory usage: {0}</p>",GC.GetTotalMemory(false)));
     }
    

    Be aware that you’ll see the usage increasing increasing until the GC kicks in and the usage will drop to a more ‘realistic’ value.

    If you have the money I recommend a specialized tool such as the Memory profiler

    Other things you can do to at least be ready if the application has memory or performance problems:

    • Proper layering of the application, means you can refactor the more inefficient parts without affecting the others.
    • The Repository pattern will be very helpful, because you can start using EF , find out that EF uses to much memory (like in the link you’ve found), but then you could switch the repository implementation to use PetaPoco or Dapper.net.
    • In general an OR\M is more of a heavy library, if the application doesn’t need ORM features but just a quick way to work with a db, use from the beginning a mico-Orm like those mentioned above.
    • Always dispose objects implementing IDisposable.
    • When dealing with large db records, use pagination. It’s good for both server resources usage and user experience
    • Apply the YAGNI (You Aint Gonna Need It) principle as much as possible, this somehow implies a bit of TDD 🙂
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: What is the best way to check for memory leaks in c++?
What's the best way to check for the euclidean distance between two points when
What is the best way to check for the existence of a session variable
What is the best way to check if a given url points to a
Whats the best way to check if a username exists in a MySQL table?
What is the best way to check if a DLL file is a Win32
What is the best way to check collision of huge number of circles? It's
What is the best way to check if a user has correct rights to
What is the best way to check if the value of an input contains
What is the best way to check that I'm logged in to Yii from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.