473,399 Members | 3,401 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,399 software developers and data experts.

Interesting Memory Issue

Jim
I am developing an ASP.Net HTTP Module used to log requests and
responses. To offload the logging, the module saves the request
information to a queue which is accessed by another thread to actually
perform the logging. The request information is saved into an object
which is then put into the queue and pulled out of the queue by the
second thread. The second thread sets the object to null when it is
done processing it.

Everything is working just fine, but I am experiencing a memory
increase on the aspnet_wp process that does not seem to go down.
Looking further into what is actually occuring, I found out that the GC
only kicks in when ASP.Net kills the asp.net processing working thread.
Only then are the finalizers (only put in for debugging purposes)
called on the objects that end up in the queue.

Is this normal operation? The issue is that under high stress, the
memory goes up to 200mb and it takes it a long time to come back down.

Nov 17 '05 #1
5 1280
If the objects remain in the queue, they are still referenced *by* the
queue. Garbage Collection can only occur when all references to an object
are 0. Are these objects removed from the queue at any point?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Complex things are made up of
Lots of simple things.

"Jim" <ji*********@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
I am developing an ASP.Net HTTP Module used to log requests and
responses. To offload the logging, the module saves the request
information to a queue which is accessed by another thread to actually
perform the logging. The request information is saved into an object
which is then put into the queue and pulled out of the queue by the
second thread. The second thread sets the object to null when it is
done processing it.

Everything is working just fine, but I am experiencing a memory
increase on the aspnet_wp process that does not seem to go down.
Looking further into what is actually occuring, I found out that the GC
only kicks in when ASP.Net kills the asp.net processing working thread.
Only then are the finalizers (only put in for debugging purposes)
called on the objects that end up in the queue.

Is this normal operation? The issue is that under high stress, the
memory goes up to 200mb and it takes it a long time to come back down.

Nov 17 '05 #2
Jim
Kevin,

The objects are dequeued from the queue by a processing thread that is
actually doing the logging. Further, I see that the objects are
destroyed, but only when the asp.net worker thread is destroyed by
asp.net. I ran another test last night where the memory got to around
250mb and came back down about 3 hours after the test itself was done.

Obviously the issue is that asp.net will keep the worker threads around
as long as there is activity on the web application and that could
cause to a potential out of memory issue.

Nov 17 '05 #3


"Jim" <ji*********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Kevin,

The objects are dequeued from the queue by a processing thread that is
actually doing the logging. Further, I see that the objects are
destroyed, but only when the asp.net worker thread is destroyed by
asp.net. I ran another test last night where the memory got to around
250mb and came back down about 3 hours after the test itself was done.

Obviously the issue is that asp.net will keep the worker threads around
as long as there is activity on the web application and that could
cause to a potential out of memory issue.

What exactly do you mean with dequeued, do you realy set the queue entry to
null? Maybe a piece of code would help.
Just take a look at the GC counters with Permon.exe, you'll see that during
a period of 3 hours the GC has kicked in a thousand times, so it's clear
that you are still holding "the" (not necessarely the queued) objects alive,
a memory profiler can reveal which objects are long living.
Willy.
Nov 17 '05 #4
Jim
Willy,

Thanks for the reply.

Here is the portion of code that pulls the objects out of the queue.
What is interesting is that the oOperation object does not get
collected until the asp.net worker thread is destoryed. To know this, I
created a finalizer where I just set an internal collection to null.
That code only executes when the thread is destroyed.

object oQueueItem;
HttpOperation oOperation;
string sOperationContent;
string
sURI=moParentMonitor.AdapterConfigInfo.EventPostEC Config.PostingUrl;
if
(moParentMonitor.AdapterConfigInfo.EventPostECConf ig.PortNumber>0)
{
sURI+=":"+moParentMonitor.AdapterConfigInfo.EventP ostECConfig.PortNumber.ToString();
}
while ( moParentMonitor.AdapterConfigInfo.MonitoringActive )
{
if (moParentMonitor.EventsQueue.Count>0)
{
lock (moParentMonitor.EventsQueue.SyncRoot)
{
oQueueItem=moParentMonitor.EventsQueue.Dequeue();
}
oOperation=(HttpOperation)oQueueItem;
oQueueItem=null;
sOperationContent=oOperation.ToXml();
HttpPost(sURI,sOperationContent);
sOperationContent=null;
oOperation=null;
lock (moAdapterStatistics)
{
moAdapterStatistics.NumOfEventsPosted+=1;
}
}
Thread.Sleep(10);
}
}
finally
{
Thread.Sleep(10);
}

Nov 17 '05 #5
Hi Jim,

Somewhere, something is keeping a reference to the object. That's what you
need to look for.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Complex things are made up of
Lots of simple things.

"Jim" <ji*********@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Willy,

Thanks for the reply.

Here is the portion of code that pulls the objects out of the queue.
What is interesting is that the oOperation object does not get
collected until the asp.net worker thread is destoryed. To know this, I
created a finalizer where I just set an internal collection to null.
That code only executes when the thread is destroyed.

object oQueueItem;
HttpOperation oOperation;
string sOperationContent;
string
sURI=moParentMonitor.AdapterConfigInfo.EventPostEC Config.PostingUrl;
if
(moParentMonitor.AdapterConfigInfo.EventPostECConf ig.PortNumber>0)
{
sURI+=":"+moParentMonitor.AdapterConfigInfo.EventP ostECConfig.PortNumber.ToString();
}
while ( moParentMonitor.AdapterConfigInfo.MonitoringActive )
{
if (moParentMonitor.EventsQueue.Count>0)
{
lock (moParentMonitor.EventsQueue.SyncRoot)
{
oQueueItem=moParentMonitor.EventsQueue.Dequeue();
}
oOperation=(HttpOperation)oQueueItem;
oQueueItem=null;
sOperationContent=oOperation.ToXml();
HttpPost(sURI,sOperationContent);
sOperationContent=null;
oOperation=null;
lock (moAdapterStatistics)
{
moAdapterStatistics.NumOfEventsPosted+=1;
}
}
Thread.Sleep(10);
}
}
finally
{
Thread.Sleep(10);
}

Nov 17 '05 #6

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

Similar topics

0
by: Savaticus | last post by:
This is VBScript centric I have an issue where in windows 2k the selectSingleNode method returns values as expected but in Windows XP I get an error Object Required:...
56
by: Dave Vandervies | last post by:
I just fixed a bug that some of the correctness pedants around here may find useful as ammunition. The problem was that some code would, very occasionally, die with a segmentation violation...
23
by: Bruno R. Dias | last post by:
Perhaps it would be interesting to program a virtual machine simulating an ancient computer (such as the pdp-7). Then, it would be rather interesting to code for it (porting gcc to it maybe?). I...
8
by: Adrian | last post by:
Hi I have a JS program that runs localy (under IE6 only) on a PC but it has a memory leak (probably the known MS one!) What applications are there that I could use to look at the memory usage of...
2
by: a_agaga | last post by:
Do you know are there some reasons why many do not make processes to communicate through memory? Why network connections (sockets) are used so commonly in IPC (inter process communication)...
27
by: Frederick Gotham | last post by:
I thought it might be interesting to share experiences of tracking down a subtle or mysterious bug. I myself haven't much experience with tracking down bugs, but there's one in particular which...
3
by: san | last post by:
we cannot stop the application from increasingly use memory. The CRM Worker process will continually consume memory but not release it back to the system. Please research into how to make the...
6
by: per9000 | last post by:
An interesting/annoying problem. I created a small example to provoke an exception I keep getting. Basically I have a C-struct (Container) with a function-pointer in it. I perform repeated calls...
0
by: Daniel Fetchinson | last post by:
The project I'm working on is motion detection, involving a bit of image It's hard to tell without looking at a stripped down, minimal version of your code that still shows the above behaviour....
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.