views:

127

answers:

4

My asp.net application is 3 static pages (no database) and it initializes with 48Mb of memory in use.

Can I configure the application to use less memory?

NB: I've already set the memory limits in IIS. I set maximum value for working process to 30 MB of physical memory.

What other ways can I employ to make ASP.NET use less memory?

+9  A: 

You have three static pages (mean that pages that do not change), and you're using ASP.NET?

Why not just serve up three static HTML pages?

As far as making ASP.NET use less memory: Why? From a server standpoint, 48MB is nothing. If that's a constraint, then you have bigger issues than whether or not to use ASP.NET.

George Stocker
48Mb is very much for Hello world asp.net application. I think there is a setting in asp.net that sets minimum memory that asp.net runtime takes at start. So I need just more precise memory control.
Alexey Shirshov
@Alexey Shirshov : 48MB is really small for a web application. Premature optimization is the root of all evil. If 48MB is your limit, then you need to not use ASP.NET.
George Stocker
48Mb is a lot for a hello world application because it's the wrong tool for the job. It's a bit like complaining that a sledge hammer is too heavy to hang a picture on the wall. Once you start building dynamic pages, you'll find that ASP.NET scales fairly well in terms of memory usage. But you're basically initializing a lot of excess logic that you will never need. ASP.NET doesn't know that your serving only static pages. It's getting itself ready to serve dynamic pages. Don't take this as a sign that ASP.NET is a memory hog, just use the right tool for the job.
senfo
@senfo - well said!
Chuck Conway
+1  A: 

You can't explicitly control how much memory ASP.NET uses. The only controls you have are at the IIS level, which basically tell IIS to recycle the worker process if the memory use exceeds a certain threshold.

If you want to reduce the memory footprint, you might try doing things like eliminating all of the HttpModules that you don't need: WindowsAuthentication, etc, etc.

RickNZ
I'm a little surprised to see Workflow modules there, but otherwise the rest looks pretty normal.When a large number of DLLs are loaded (your screenshot shows 111 of them), app size can be driven by odd base addresses, conflicting DLL base addresses and rebasing. You would really need to look at a detailed memory map to know more...
RickNZ
The following assemblies are loaded into applicationSystem.IdentityModelSystem.ServiceModelSystem.ServiceModel.WebSystem.WorkflowServicesSystem.CoreSystem.Web.RoutingSystem.Web.AbstractionsAmong them System.ServiceModel is the most huge (16.5 Mb). How can I eliminate it?
Alexey Shirshov
Ok, I remove it. Here is new picture - http://imagebin.ca/view/KGT-6h.html. Now the program takes only 24 Mb.
Alexey Shirshov
A: 

Thank you, RickNZ. I turned off all modules I dont need, but it doesn't help. I run Debug Diagnostics tool and here is result. Any comments?

Alexey Shirshov
The answer has been given in the comments. You're loading a lot of .NET code because ASP.NET is about running *.NET code*, it doesn't care that you don't use all those things. Just drop using an ASP.NET project and just dump the three static pages into a folder for IIS to serve.
Lasse V. Karlsen
A: 

There will always be a baseline minimum amount of memory required to start even the most basic of ASP.NET applications. This is because there's not just your application but there's also the ASP.NET infrastructure, CLR and assorted plumbing being loaded into the worker process (and whatever memory reservations the managed heap is making up front).

Stop worrying about this until you encounter real memory pressure issues such as leaks. What you're seeing is normal.

Kev