By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,864 Members | 1,218 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,864 IT Pros & Developers. It's quick & easy.

ASP.NET memory management

P: n/a
We're developing our first large scale ASP.NET web application and I'm a
little concerned over memory usage of aspnet_wp.exe on the development
server during testing. The application appears to use a lot of memory and
I've got the feeling that it's not all been released.

Some initial questions:

When a session times out, is ASP.NET/CLR supposed to release every resource
allocated during the session?

Is there anyway to display what's happening on a IIS server when it's
running an application? A log of some kind. Just memory per session would be
a start.

Are there any configuration options around memory management of ASP.NET on
IIS?

Despite what I've heard, do you actually have to carry out manual disposal
and memory collection. I've come from the VB6 world where the classic
circular reference (Obj1 points to Obj2 and Obj2 points to Obj1) causes both
objects (and their children) to stay in memory even though Obj1 and Obj2 are
both cleared to nothing. I currently believe the dream that CLR garbage
collection does work. I hope I can carry on with this dream... Waking up
into reality and having to implement cleanup code throughout the application
is more of a nightmare than a dream.

Cheers, Rob.


Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
HI Rob, see inline:

On Wed, 27 Jul 2005 09:56:20 +0100, "Rob Nicholson"
<in******@community.nospam> wrote:
We're developing our first large scale ASP.NET web application and I'm a
little concerned over memory usage of aspnet_wp.exe on the development
server during testing. The application appears to use a lot of memory and
I've got the feeling that it's not all been released.

Some initial questions:

When a session times out, is ASP.NET/CLR supposed to release every resource
allocated during the session?

Memory resources will be taken care of by the garbage collector -
eventually. Chances are it will not happen at the exact moment a
session times out. Server processes in general tend to not give up
memory easily, chances are they will need it again in the future.
Chances are you may not have a problem, the best way to find out would
be to do some simulated stress testing. Saying a process uses "a lot"
of memory is too relative.
Is there anyway to display what's happening on a IIS server when it's
running an application? A log of some kind. Just memory per session would be
a start.

You could start with perfmon, which comes with the operating system.
Under the .NET CLR Memory counter category pay particular attention to
the Large Object Heap size and Gen 2 heap size. These areas contain
the large objects and the objects that are hanging around the longest.

There are also memory profilers you can use - CLRProfiler is free [1].
WinDbg [2] is the best tool for seeing exactly what you have on the
heap, but has a steep learning curve and too many details for most
memory scenarios. Still, the latest version has an extension command
(!dac for DumpAspnetCache) that can show you exactly what is in the
cache (ASP.NET keeps Sessions in the Cache collection internally).
Are there any configuration options around memory management of ASP.NET on
IIS?

You can set q peak amount of memory for the worker process to use,
once it hits this number the application recycles, which might not be
what you want. In IIS 6.0 this is set on the Application Pool
properties dialog.
Despite what I've heard, do you actually have to carry out manual disposal
and memory collection. I've come from the VB6 world where the classic
circular reference (Obj1 points to Obj2 and Obj2 points to Obj1) causes both
objects (and their children) to stay in memory even though Obj1 and Obj2 are
both cleared to nothing. I currently believe the dream that CLR garbage
collection does work. I hope I can carry on with this dream... Waking up
into reality and having to implement cleanup code throughout the application
is more of a nightmare than a dream.


Circular references are definitely not a problem in .NET.
[1]
http://www.microsoft.com/downloads/d...displaylang=en

[2] http://www.microsoft.com/whdc/devtoo...g/default.mspx

--
Scott
http://www.OdeToCode.com/blogs/scott/
Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.