OutOfMemoryException on IIS 5.0 with .net framework 1.1.4322, please advice

Posted on 2004-11-28
Last Modified: 2012-05-05
We are haveing more and more OutOfMeomoryException these days, at first, it happened once a week, now three times a week. The worst thing is, IIS didn't recycle its aspnet_wp.exe thread when this exception was thrown. And every one tried to connect IIS server now saw this error.

Our configuration is as follow,
Windows server 2000,
2 Xeon CPU
2GB memory
3.7GB free space on system drive, and much more on other drives
IIS 5.0 with net framework v1.0.3705 and v1.1.4322.573 installed
All the web applications are configurated to run with .net framework v1.1.4322.573

Average daily page views is about 100,000, all the isolation level are set to medium.

MemoryLimit in all web.config files are set to default value at 60 percent. The consumed memory of aspnet_wp.exe was at only 600MB as the OutOfMemoryException happened, much lower than 2GB*605 = 1.2GB.  I read quite a few threads on line, some said that the MemoryLimit of .net framework 1.0 should be set to no more than 800MB if not with /3GB switched on. But I found no article to confirm whether this also  appliest to .net framework 1.1. Could anyone explain it for me?

I also recognized that Microsoft admiitted there is a bug in .net framework 1.1 which would report OutOfMemoryException when there is pretty much memory available, the hot fix was bundled in .net framework 1.1 SP1. However, in my situation because it is a production system used by hundreds of people, we dare not to apply such a big change without concrete evidence.

My question is what should I do, I mean to change the IIS settings, or settings in web.config files, to minimize impact of this OutOtMemoryExceptions? I guess it would also be acceptable, if IIS recycle its aspnet_wp.exe thread when it goes out of memory rather than refuse any more connection.

Any advice is appreciated.
Question by:toString
    LVL 34

    Expert Comment

    IIS has no control over the ASP.Net worker process - it is a seperate process.

    If you are running into the problem described in the hotfix you should all Microsoft and get the hotfix.  If you are calling to get a hotfix there is no charge for the call.

    Dave Dietz

    Expert Comment

    Is your code trying to access a COM component?
    Alternatively try explicitly closing and disposing any open connections after you are done with the processing.

    Hope this helps.

    Author Comment

    Thanks for both your advices.

    As far as I know, we have no web application accessing any COM component.

    But I do have a suspicious culprit, we transfer report source to Crystal Report Viewer objects via  session variables. A single object might taken 3-5 MBs of memory, I guess this is a really bad practice but I can't prove it is the root cause.

    I don't have to call MS to have the hot fix, it is budled into .net framework SP1 for free. My concern is they fixed many problems in this service pack, we can't apply the service pack before it is fully tested with our applications.

    Expert Comment

    Do you explicitly close and dispose Crystal report viewer object?

    We had faced a similar problem with Crystal report object and there the solution suggested by Microsoft was to explicity close and dispose the objects.
    This has certainly reduced the number of occurances of the problems.
    There is a known memory leak problem with Crystal Reports and .NET.

    Do you use SETDATASOURCE method anywhere in your code?


    Author Comment

    No, we do not explicitly close/dispose Crystal Report viewer object.

    Actually, we have a common page which holds a CR viewer object as below,
       <form id="Form1" method="post" runat="server">
          <CR:CRYSTALREPORTVIEWER id="CrystalReportViewer1" style="Z-INDEX: 101; LEFT: 1px;
             POSITION: absolute; TOP: 2px" runat="server" Width="350px" Height="50px"
             DisplayGroupTree="False" HasSearchButton="False" EnableDrillDown="False"
             HasDrillUpButton="False" HasToggleGroupTreeButton="False"

    Then in code behind,
        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
          Handles MyBase.Load
                objReport = Session("Report")
                With CrystalReportViewer1
                    .ReportSource = objReport.crReport
                End With
            Catch ex As Exception
                'error handling code here
            End Try
        End Sub

    Here objReport is a customized class that has following members,
        Public Class crReport
            Private ParaFieldDefs As ParameterFieldDefinitions
            Private Report As New ReportDocument()
            Private Connection As New ConnectionInfo()
            Private Parameters As New ReportParameters()
            Private TemplateFile As String
        End Class

    By the way, I found no "close" but only "dispose" method for crystal report viewer objects. Am I overlooking sometihng? And is it reasonable to dispose this object when placed on a web page?

    Thanks for your input in advance!

    Expert Comment

    Inside class crReport, we have a ReportDocument object.
    Could you try both closing and disposing the objects in crReport class?

    Notes from MSDN:
    Call Dispose when you are finished using the CrystalReportViewer. The Dispose method leaves the CrystalReportViewer in an unusable state. After calling Dispose, you must release all references to the CrystalReportViewer so the memory it was occupying can be reclaimed by garbage collection.

    Note   Always call Dispose before you release your last reference to the CrystalReportViewer. Otherwise, the resources that the CrystalReportViewer is using will not be freed until garbage collection calls the CrystalReportViewer object's destructor.


    Author Comment

    Thanks deeptinayak, I'll try and monitor how it goes on, for a few more days.

    Author Comment

    According to my examination, closing and disposing Crystal Report has no immediate effect to allocated memory of aspnet_wp.exe, how long should I wait, or is there any other indicator can tell me there are more memory ready to be reclaimed by GC?
    LVL 34

    Expert Comment

    Have you considered getting the hotfix (as opposed tothe whole SP1 package) yet?

    Dave Dietz

    Author Comment

    Microsoft doesn't provide standalone hotfix for the mentioned OutOfMemory bug, has to install the whole 1.1. SP1 package.

    Accepted Solution

    One more go:
    Try taking the memory dump at the time of the problem and there are tools available at to analyse the memory dumps. The analysis will tell you the number of processes active at that time and the memory consumption etc.

    Do you have Microsoft support for your project?
    If yes, you can ask them to analyse the same for you.

    Author Comment

    We have Microsoft support for global projects but unfortunately, this one is a local project.

    As for memory dump, that's exactly what I am going to do, I am reading the Microsoft book on production environment debugging, not quite understand the material yet.

    Thanks for your commments, deeptinayak.

    Author Comment

    Later on I found, based on performance counters and IIS logs, certain pages returned
    tens of thousands of records without pagination. This could easily lead the IIS server
    into OutOfMemoryException status.

    But I don't know why it doesn't trigger OutOfMemoryException when data gathered as below,

    .Net CLR Memory
       # Total commited Bytes 499,940,944
       # Total reserverd Bytes 603,979,344

    Process aspnet_wp
       Virtual Bytes 1,089,425,408

    Sum up these three is about 2.04GB which already exceeds virutal address limit of process, that is, 2.0GB.

    But IIS worked on for 30 more minutes that day.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Suggested Solutions

    Today I came across an interesting issue that had me pulling my hair out.  I was troubleshooting a new internal web site which uses integrated security instead of anonymous.  When browsing the site from my laptop, I was able to access it with no iss…
    What is an ISAPI filter?   •      It's an assembly (.dll file) that can add or change the way IIS works.   •      They can be enabled globally for your web server or on a site-by-site basis.   When the IIS server receives a request, enabling the ISAPI fi…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now