Link to home
Start Free TrialLog in
Avatar of toString
toString

asked on

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

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.
Avatar of Dave_Dietz
Dave_Dietz
Flag of United States of America image

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
Avatar of deeptinayak
deeptinayak

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.
Avatar of toString

ASKER

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.
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?




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"
         HasRefreshButton="True"></CR:CRYSTALREPORTVIEWER>
   </form>

Then in code behind,
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
      Handles MyBase.Load
        Try
            objReport = Session("Report")
            objReport.SetParameter()
            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!
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.

Thanks deeptinayak, I'll try and monitor how it goes on, for a few more days.
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?
Have you considered getting the hotfix (as opposed tothe whole SP1 package) yet?

Dave Dietz
Microsoft doesn't provide standalone hotfix for the mentioned OutOfMemory bug, has to install the whole 1.1. SP1 package.
ASKER CERTIFIED SOLUTION
Avatar of deeptinayak
deeptinayak

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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.