Out of memory problem for ASP.NET/IIS6.... How to evaluate how much memory is available to web instance?

Hi,

I have an ASP.NET application on a shared IIS6 server with 4GB RAM. There are quite a lot of other sites on this server, at least 20. There is no memory capping setup for any site, it is all default IIS6 setup. I am getting "out of memory exception" errors. We have setup Application Pool Recycling every 24hours. Now I realise that any potential memory leak should be plugged. However I am concerned that the amount of memory available to this application could decrease to problematic levels due to high activity of other sites. Therefore I want to put in some code that extracts the value of memory that is available to my Web site when it crashes, or memory available to my application pool.

So it may be 1GB is free and available off the server to my app pool however this might go down to say 200mb which would make "out of memory" errors more likely.

Thoughts???

Thanks,

Sam
SamJollyAsked:
Who is Participating?
 
Alfred A.Connect With a Mentor Commented:
Hi Sam,

Ok.  My suggestion then is to start with handling exceptions that can happen in your application.  Even with a simple thrown error can use up quite a resource in memory.  What you can do is to check the event viewer for any unhandled exceptions in the Application Event Log in the Server (assuming you have access to the server).

I got burned with this when I implemented a WSE 3.0 web service that handles 600KB size data and concurrently hitting it around 12 per sec.  One simple error caused a massive leak in memory and caused an out-of-memory error during load testing.

A simple try-catch scenario in typical areas should be a good start.

I hope this helps.
0
 
Alfred A.Connect With a Mentor Commented:
Hi,

Have you tried creating multiple application pools and dividing your websites to an application pool?  As I recall, there is a 1GB limit within a w3wp.exe (application pool) in a Win2003 Server.  If you combine all 20 web sites into just one application pool, you might really hit the limit and get an "out of memory" error.

Also, unhandled error exception can also cause the size of the w3wp.exe to grow based on my experience.  





0
 
corneliu_newsCommented:
You can try with this first
http://support.microsoft.com/kb/911716

To monitor the app memory usage you can use Ants profiler - is best one I know.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
SamJollyAuthor Commented:
Hi Folks.

Thanks for this.

So there is no way for the asp.net code to access some memory variable value?? One has to rely on 3rd party tools such as ANTS profiler which I have and investigating to sort out the memory leak in the code?

Sam
0
 
SamJollyAuthor Commented:
Alfred,

I have a specific App Pool for my application/ IIS web instance

Sam
0
 
corneliu_newsCommented:
I don't think you can call profiling API's from managed code, you can only attach a profiler to a running managed process.
0
 
corneliu_newsConnect With a Mentor Commented:
0
 
SamJollyAuthor Commented:
Folks,

Thanks for the comments and tips. However I still do not know how to get the available memory value for the host web iis instance. If I can get this then I might find that it is not my code, but the share hosting environment which is not providing enough RAM. I really could do with getting this figure.

I am encountering quite a number of errors in production use, particularly "Invalid Viewstate" although the users are not complaining. Some of them may be behind the scences since we log all raised exceptions.

Thanks again,

Sam
0
 
SamJollyAuthor Commented:
Sorry about leaving this. No I do want to allocate points since I appreciate the help.

Sam
0
 
SamJollyAuthor Commented:
How do I shre the allocation? Cannot see the button?

Sam
0
 
Alfred A.Commented:
@cs97jjm3,

Please read Sam's comments ID 32269964 and 32270136.  Thanks.

Regards,

Alfred1
0
 
SamJollyAuthor Commented:
thx
0
All Courses

From novice to tech pro — start learning today.