you are probably "leaking" unmanaged com memory by not releasing com
references when done, but rather letting the gc do it.
when your code is done with a com object it should call
Marshal.ReleaseComObject. also you should never use more than one dot when
referencing a com object or you will have a leak.
ex:
// create com object
MyComObject a = new MyComObject();
// call 2 dot method wrong way
a.b.c(); // leaks b, only gc will release
// call 2 dot correct
MyComBType b = a.b;
b.c();
Marshal.ReleaseComObject(b);
b = null;
// release com object
Marshal.ReleaseComObject(a);
a = null;
tedious, but necessary.
-- bruce (sqlwork.com)
"Noman Ali" wrote:
Quote:
Hi,
>
We are facing a strange problem in our ASP. NET website. Some times it gives
the following unhandled exception.
>
Error Message: Exception of type System.Web.HttpUnhandledException was thrown.
Detailed Error Message: System.InvalidOperationException: There has been an
overflow or underflow in GC memory pressure. The possible cause is unbalanced
AddMemoryPressure and RemoveMemoryPressure calls.
at System.MemoryWatcher.AddMemoryPressure(Int64 size)
at System.GC.AddMemoryPressure(Int64 pressure)
at WebApplication1.CFileUtils.ProcessFile(String filename)
at WebApplication1.CBanner.CreateStringTag(String appPath, Int32 width,
Int32 height, String& ext)
at WebApplication1.CAdRotator.DisplayBanners(HtmlTabl e table, String
position, String queryStr, String[]& displayed)
at WebApplication1.TopBanner.Page_Load(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain()
>
I already did some research on it and found that it is caused when you add
and remove unbalanced memory pressure on GC. But we are not doing that. The
exception comes during peak hours of our site and it comes randomly normally
after 12-14 hours daily and after that we needs to restart the asp .net
worker process. The worker process uses around 50% of the system memory
during this abnormal behaviour. The web application heavily uses some
unmanaged COM components for PDF and image manupulation.
>
What i had done so far, i forefully calls garbage collection after every
hour so that COM components will be garbage collected. I am identifying
memory leaks in the web application but still i think the problem is
different.
>
Any suggestion, comments or experience will be welcome.
>
Regards,
Noman Ali