MQ内存泄漏 [英] MQ memory leak

查看:73
本文介绍了MQ内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我已经实现了一个服务,负责从位于远程计算机上的

MS MQ获取消息。我不时得到内存泄漏

(???)。在某些情况下,它更容易重现(例如:远程机器

不可用)。大约1天后,我得到300MB内存的使用。

我使用.NET Memory Profiler工具试图查看泄漏位于
的位置。对于所有泄漏的实例,我可以看到以下内容(我应该说

不太清楚它试图显示的内容......):


Message..ctor(MessagePropertyFilter)

MessageQueue.ReceiveCurrent(TimeSpan,int,IntPTR,MessagePropertyFilter,

......)

MessageQueue.Receive(TimeSpan)

MQEvlReceiver.Receive(int)< --------我的应用程序。

MQReception.DoWork()< - -------我的应用。


我检查并重新检查我的代码,我看不出任何问题。


有没有人知道类似情况下MQ泄漏?


这是我的配置:

W2K sp3 english

..网络1.1


谢谢,
$ b $bJosé

解决方案

Jose ,


您是否在所使用的所有课程上调用Dispose?对于

示例,您是否在正在使用的MessageQueue实例上调用Dispose?

这可能是您可能看到的任何泄漏的主要来源。


希望这会有所帮助。

-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


"JoséJoye" <乔******* @ KILLTHESPAMSbluewin.ch>在留言中写道

新闻:e7 ************** @ TK2MSFTNGP10.phx.gbl ...


我已经实现了一个服务,负责从位于远程计算机上的
a MS MQ获取消息。我的内存泄漏从时间到
时间(???)。在某些情况下,它更容易重现(例如:远程机器
不可用)。大约1天后,我得到300MB内存的使用。
我使用.NET Memory Profiler工具试图查看泄漏的位置。对于所有泄漏的实例,我可以看到以下内容(我应该说
说不太清楚它试图显示的内容......):

Message..ctor(MessagePropertyFilter)
MessageQueue.ReceiveCurrent(TimeSpan,int,IntPTR,MessagePropertyFilter,
.....)MessageQueue.Receive(TimeSpan)
MQEvlReceiver.Receive(int)< - ------我的应用。
MQReception.DoWork()< --------我的应用。

我检查并重新检查我的代码,我看不出任何问题。

在类似情况下有没有人知道MQ的泄漏?

这是我的配置:
W2K sp3 english
.NET 1.1

谢谢,
José



实际上,在进入我的循环之前,我创建了一个类的实例,它将尝试获取消息。这个类有一个私有成员:

私有MessageQueue m_mq;


在主循环调用的方法中,每当我尝试获取一个

消息,我使用m_mq.Receive(TimeToWait)。

如果检索到消息,我会将其传递回主循环。在任何其他

情况下,我返回null。


有一种情况我在我的m_mq上调用Dispose()方法。会员。这个

是我收到MessageQueueErrorCode.QueueNotAvailable类型的错误。在

这种情况​​下,我应用以下算法:

m_mq.Dispose();

m_mq = null;

MessageQueue.ClearConnectionCache();

m_mq = new MessageQueue(m_strQueueName);

MessageQueue.EnableConnection = true;

当主要循环接收答案(消息或空),它将处理消息并再次调用该方法以获取下一条消息。


In那种感觉,我想我没有忘记给任何Dispose()打电话。

$ b $bJosé


" Nicholas Paldino [.NET / C# MVP] QUOT; < mv*@spam.guard.caspershouse.com> aécrit

dans le message de news:et ************** @ TK2MSFTNGP10.phx.gbl ...

Jose,

您是否在所有正在使用的课程上调用Dispose?对于
示例,您在MessageQueue实例上调用Dispose是否为
使用?这可能是您可能看到的任何泄漏的主要来源。

希望这会有所帮助。

-
- Nicholas Paldino [.NET / C#MVP]
- mv*@spam.guard.caspershouse.com

JoséJoye ; <乔******* @ KILLTHESPAMSbluewin.ch>在消息中写道
新闻:e7 ************** @ TK2MSFTNGP10.phx.gbl ...


我已经实现了一个服务,负责从

位于远程计算机上的MS MQ获取消息
。我的内存泄漏从


时间

(???)。在某些情况下,它更容易重现(例如:远程



机器不可用)。大约1天后,我得到300MB内存的使用。
我使用.NET Memory Profiler工具试图查看泄漏的位置。对于所有泄漏的实例,我可以看到以下内容(我应该


这不太清楚它试图显示的内容......):

Message..ctor(MessagePropertyFilter)
MessageQueue.ReceiveCurrent(TimeSpan,int,IntPTR,
MessagePropertyFilter,.....)
MessageQueue.Receive(TimeSpan)
MQReception.DoWork()< --------我的应用程序
我检查并重新检查我的代码,我看不出有任何问题。

在类似的情况下有没有人知道MQ泄漏?

这是我的配置:
W2K sp3 english
.NET 1.1
谢谢,
José




>

您是否在所有正在使用的类上调用Dispose?对于
示例,您在MessageQueue实例上调用Dispose是否为
使用?这可能是您可能看到的任何泄漏的主要来源。


我们为什么要手动调用Dispose()?不应该叫Close()是否足够?
?当物体即将被收集并且不应该被称为manualy时,我认为将会调用dispose。


/ m

希望这会有所帮助。

-
- Nicholas Paldino [.NET / C#MVP]
- mv*@spam.guard.caspershouse.com

JoséJoye <乔******* @ KILLTHESPAMSbluewin.ch>在消息中写道
新闻:e7 ************** @ TK2MSFTNGP10.phx.gbl ...


我已经实现了一个服务,负责从

位于远程计算机上的MS MQ获取消息
。我的内存泄漏从


时间

(???)。在某些情况下,它更容易重现(例如:远程



机器不可用)。大约1天后,我得到300MB内存的使用。
我使用.NET Memory Profiler工具试图查看泄漏的位置。对于所有泄漏的实例,我可以看到以下内容(我应该


这不太清楚它试图显示的内容......):

Message..ctor(MessagePropertyFilter)
MessageQueue.ReceiveCurrent(TimeSpan,int,IntPTR,
MessagePropertyFilter,.....)
MessageQueue.Receive(TimeSpan)
MQReception.DoWork()< --------我的应用程序
我检查并重新检查我的代码,我看不出有任何问题。

在类似的情况下有没有人知道MQ泄漏?

这是我的配置:
W2K sp3 english
.NET 1.1
谢谢,
José




Hi,

I have implemented a Service that is responsible for getting messages from a
MS MQ located on a remote machine. I''m getting memory leak from time to time
(???). In some situation, it is easier to reproduce (e.g.: remote machine
not available). After about 1 day, I get a usage of 300MB of memory.
I have used .NET Memory Profiler tool to try to see where the leak is
located. For all the leaky instances, I can see the following (I should say
that is not too clear what it is trying to show...):

Message..ctor(MessagePropertyFilter)
MessageQueue.ReceiveCurrent(TimeSpan, int, IntPTR, MessagePropertyFilter,
......)
MessageQueue.Receive(TimeSpan)
MQEvlReceiver.Receive(int) <--------My appl.
MQReception.DoWork() <--------My appl.

I have check and re-check my code, I cannot see any problem with it.

Does anyone knows about a leak with MQ in a similar case?

Here is my config:
W2K sp3 english
..NET 1.1

Thanks,
José

解决方案

Jose,

Are you calling Dispose on all of the classes that you are using? For
example, are you calling Dispose on the MessageQueue instance you are using?
This could be a major source of any leaks you might be seeing.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"José Joye" <jo*******@KILLTHESPAMSbluewin.ch> wrote in message
news:e7**************@TK2MSFTNGP10.phx.gbl...

Hi,

I have implemented a Service that is responsible for getting messages from a MS MQ located on a remote machine. I''m getting memory leak from time to time (???). In some situation, it is easier to reproduce (e.g.: remote machine
not available). After about 1 day, I get a usage of 300MB of memory.
I have used .NET Memory Profiler tool to try to see where the leak is
located. For all the leaky instances, I can see the following (I should say that is not too clear what it is trying to show...):

Message..ctor(MessagePropertyFilter)
MessageQueue.ReceiveCurrent(TimeSpan, int, IntPTR, MessagePropertyFilter,
.....)
MessageQueue.Receive(TimeSpan)
MQEvlReceiver.Receive(int) <--------My appl.
MQReception.DoWork() <--------My appl.

I have check and re-check my code, I cannot see any problem with it.

Does anyone knows about a leak with MQ in a similar case?

Here is my config:
W2K sp3 english
.NET 1.1

Thanks,
José



In fact, before entering my loop, I create an instance of a class that will
try to fetch messages. This class has a private member :
private MessageQueue m_mq;

Within the method called by the main loop, whenever I try to fetch a
message, I use m_mq.Receive(TimeToWait).
In case a message is retrieved, I pass it back to my main loop. In any other
situation, I return a null.

There is a situation where I call Dispose() method on my "m_mq" member. This
is when I get an error of type MessageQueueErrorCode.QueueNotAvailable. In
such a case, I apply the following algorithm:
m_mq.Dispose();
m_mq=null;
MessageQueue.ClearConnectionCache();
m_mq = new MessageQueue(m_strQueueName);
MessageQueue.EnableConnection = true;
When the main loop receive the answer (either a message or a null), it will
process the message and call the method again to get the next message.

In that sense, I think I did not forgot to call any Dispose().

José

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> a écrit
dans le message de news:et**************@TK2MSFTNGP10.phx.gbl...

Jose,

Are you calling Dispose on all of the classes that you are using? For
example, are you calling Dispose on the MessageQueue instance you are using? This could be a major source of any leaks you might be seeing.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"José Joye" <jo*******@KILLTHESPAMSbluewin.ch> wrote in message
news:e7**************@TK2MSFTNGP10.phx.gbl...

Hi,

I have implemented a Service that is responsible for getting messages from

a

MS MQ located on a remote machine. I''m getting memory leak from time to


time

(???). In some situation, it is easier to reproduce (e.g.: remote


machine not available). After about 1 day, I get a usage of 300MB of memory.
I have used .NET Memory Profiler tool to try to see where the leak is
located. For all the leaky instances, I can see the following (I should


say

that is not too clear what it is trying to show...):

Message..ctor(MessagePropertyFilter)
MessageQueue.ReceiveCurrent(TimeSpan, int, IntPTR, MessagePropertyFilter, .....)
MessageQueue.Receive(TimeSpan)
MQEvlReceiver.Receive(int) <--------My appl.
MQReception.DoWork() <--------My appl.

I have check and re-check my code, I cannot see any problem with it.

Does anyone knows about a leak with MQ in a similar case?

Here is my config:
W2K sp3 english
.NET 1.1

Thanks,
José




>

Are you calling Dispose on all of the classes that you are using? For
example, are you calling Dispose on the MessageQueue instance you are using? This could be a major source of any leaks you might be seeing.
Why should we call Dispose() manually? Shouldn''t be calling Close() is
enough? I thought dispose will be called when the object is about to be
garbage collected and shouldn''t be called manualy.

/m

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"José Joye" <jo*******@KILLTHESPAMSbluewin.ch> wrote in message
news:e7**************@TK2MSFTNGP10.phx.gbl...

Hi,

I have implemented a Service that is responsible for getting messages from

a

MS MQ located on a remote machine. I''m getting memory leak from time to


time

(???). In some situation, it is easier to reproduce (e.g.: remote


machine not available). After about 1 day, I get a usage of 300MB of memory.
I have used .NET Memory Profiler tool to try to see where the leak is
located. For all the leaky instances, I can see the following (I should


say

that is not too clear what it is trying to show...):

Message..ctor(MessagePropertyFilter)
MessageQueue.ReceiveCurrent(TimeSpan, int, IntPTR, MessagePropertyFilter, .....)
MessageQueue.Receive(TimeSpan)
MQEvlReceiver.Receive(int) <--------My appl.
MQReception.DoWork() <--------My appl.

I have check and re-check my code, I cannot see any problem with it.

Does anyone knows about a leak with MQ in a similar case?

Here is my config:
W2K sp3 english
.NET 1.1

Thanks,
José




这篇关于MQ内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆