MSMQ Destruction

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello

I have created MessageQueue called Req_MSMQ and have a PeekCompleted event added as follow
Req_MSMQ.PeekCompleted += new PeekCompletedEventHandler(OnRequestPeeked)
Req_MSMQ.BeginPeek()

When I destroy this object (Req_MSMQ) as follow, It doesn't clean up Memory properly.
Req_MSMQ.PeekCompleted -= new PeekCompletedEventHandler(OnRequestPeeked)
Req_MSMQ.Dispose()

But If i don't create the PeekCompleted event, everything looks fine

I used System.GC.GetTotalMemory(true) to get the free mem.. I know GC staff!!!... It eventually goes out of resources on long run. That is bad

Thanks in advanc

Bob An
(e-mail address removed)
 
I had a similar problem
although I wasn't using an event callback, just a timeout on the peek

Usually, its a good idea to set the object to null as well as call Dispose. Same thing happens in java

try setting the object to null so as to indicate to the GC that there are no references and that its safe to actually clean out the object

Calling System.GC.Collect is merely a suggestion to the GC to run, it doesn't force GC -- at least that's what I've read in other groups and sites

FWI
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top