I have an MSMQ client app which basically does this (sorry for the
psueso-psuedo-code):
TimeSpan timeout = new TimeSpan( 0, 0, 1, 0, 0 );
while( true )
{
try
{
Message m = messageq.Receive( timeout );
MyType[] mytype = (MyType[])m.Body;
}
catch( MessageQueueException e )
{
if( e.MessageQueueErrorCode == MessageQueueErrorCode.IOTimeout )
continue;
else
return;
}
}
The app memory usage climbs while running and consuming messages, eventually
peaking at ~130 when the queue is emptied. The length of the mytype array is
50 or less, and MyType is a quite small as well. Ordinarly this app wouldn't
run over 5MB. My guess was the GC just didn't have a chance to cleanup, but
once the queue is empty the app sits idle in one minute intervals waiting
for new messages - and yet the memory stays up, sometimes for half an hour.
Once the the GC fires, the memory drops to ~1MB.
I know it's a no-no to force the GC, so is there something I could fix in my
coding style? When I ran this against a very large set of messages I
actually got a "running low on virtual memory" from windows, so I need to so
something different.
Thanks,
-Ed Evans
You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.