ASP.NET Config files: Un-necessary Strings

We have been using ANTS Profiler lately to understand the memory behaviour of our ASP.NET application. What we observed is

  1. Too much memory have been allocated by Strings Objects.
  2. These string objects survives across many GC collection.

When we drill those strings more, we discovered

  1. That these are not our strings.
  2. Actually ASP.NET loads the settings of machine.config and web.config into the memory.
  3. I can now make out why it need to unload the AppDomain when we change these config files as the environment have to reload the settings again.
  4. There are many settings in these config files which have no relevance to our application.
  5. So we started commenting or removing from the machine.config file. (We took the backup of the ORIGINAL file).
  6. For e.g. webPart settings. We removed the entire block.
  7. We tested our web application and found everything to work fine.
  8. We then started removing those un-necessary entries.
  9. We then used the ANTS profiler to profile the memory and found that we save some 58 MB of memory by doing so.
  10. There was direct impact on the Gen 0 collection.

We haven’t decided whether we will do these on our production server but these can be done provided our application is the only app being used on that server.

Please take appropriate backup before trying this out.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: