473,387 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

GC memory pressure problem in using unmanaged components

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
Jan 17 '08 #1
2 4872
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:
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
Jan 17 '08 #2

Hi bruce barker,

Thanks for the reply. There is a probablity of memory leak but i dont think
that the given exception is a result of memory leak. Normally memory leaks
results in an out of memory exception. However the given exception is related
to unbalaced addition in GC memory pressure.

The important thing is that we are using ASP . NET 1.1 and
System.GC.AddMemoryPressure is not available in .NET 1.1 version.

Regards,
Noman Ali

"bruce barker" wrote:
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:
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
Jan 21 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Justin Lazanowski | last post by:
Cross posting this question on the recommendation of an I have a .NET application that I am developing in C# I am loading information in from a dataset, and then pushing the dataset to a grid,...
9
by: Mike P | last post by:
I know everything about reference counting and making sure you don't have large objects lying around. I have also profiled my app with multiple tools. I know about the fact GC collects memory but...
12
by: Andla Rand | last post by:
Hi, I almost feel like giving up on developing on dotnet. I have done several threaded programs with the goal to parse webpages and I have tried WebClient and then WinSock. Both programs has...
7
by: Rich Denis | last post by:
Hello, I have been trying to solve a mysterious memory leak problem and was hoping that you could help me out on my stuck point. First a bit of background. We have two app servers in an app...
9
by: Anton | last post by:
{Willy Skjveland} Hi, how can I trace a Memory leak in aspnet_wp.exe? {Rheena} One moment please while I search it for you. It may take me a few moments {Willy Skjveland} I need to find out...
13
by: Nikolay Petrov | last post by:
I've got this issue: When I start my application it takes a lot of memory. I guess this is caused by CLR. That's fine. But every time the app performs an action (open new form, load data in...
30
by: MAG1301 | last post by:
I've detected memory leaks in our huge .NET 1.1 C# application but couldn't localize them directly. So I've reduced the code to the following console application: using System; using System.IO;...
7
by: Ragnar Agustsson | last post by:
Hi all I have been wandering about the best way to sandbox memory leaks in 3rd party libraries when using them from the .Net framework. I have a 3rd party library, written in C++, that leaks a...
22
by: Simon | last post by:
Hi all, I have a huge memory leak problem in what is really very simple data insert code. In my app I'm trying to use a typed dataset to insert into a database. It adds quite a few rows (say...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.