菜单项泄漏 [英] Menu Items Leaking

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

问题描述

我有一个带有单个子表单的MDI表单。我发现了几个

的情况,这些情况似乎导致框架泄漏Int32s,MenuItems,

MenuItemCollections,有时甚至是TRACKMOUSEEVENTs。如果我支持/ b $ b禁用/启用menuitem,以编程方式添加新的menuitem或单击mdiList菜单中的

条目,则会发生这种情况。我正在处理子菜单中的主菜单

以及主要的mdi形式,所以这不是问题。


我有见过 http://support.microsoft.com /default...b;en-us;817723

看起来是相同或密切相关的问题,但

微软说这个在.NET Framework的v1.1中修复了错误(

就是我正在使用的)。


使用.NET Memory Profiler来自SciTech似乎这些泄露的

对象被保存在MenuItem中的allCreatedMenuItems哈希表中。我可以通过使用反射访问并清除MDI Dispose中的
哈希表来解决这个问题,但我的公司对此并不满意

解决方案。他们更喜欢基于微软或推荐的

解决方案。


这是一个在框架中的已知错误,是否有任何人的修补程序/>
知道吗?有什么建议吗?


谢谢,

Rich

I have an MDI form with a single child form. I have found a couple of
circumstances that appear to cause the framework to leak Int32s, MenuItems,
MenuItemCollections and sometimes TRACKMOUSEEVENTs. This happens if I
disable/enable a menuitem, add a new menuitem programatically or click on an
entry in the mdiList menu. I am disposing the main menu in the child form
as well as in the main mdi form, so that''s not the issue.

I have seen http://support.microsoft.com/default...b;en-us;817723
which appears to be either the same or a closely related issue, but
Microsoft says that this bug was fixed in v1.1 of the .NET Framework (which
is what I''m using).

Using the .NET Memory Profiler from SciTech it appears that these leaked
objects are being held in the allCreatedMenuItems hashtable in MenuItem. I
can hack around this problem by using reflection to access and clear that
hashtable in the MDI Dispose, but my company isn''t comfortable with this
solution. They would prefer either a Microsoft based or recommended
solution.

Is this a know bug in the framework and is there a hotfix for it that anyone
knows of? Any suggestions?

Thanks,
Rich

推荐答案



Rich B. < RI ****** @ hotmail.com>在消息中写道

news:ug ************** @ TK2MSFTNGP12.phx.gbl ...

"Rich B." <ri******@hotmail.com> wrote in message
news:ug**************@TK2MSFTNGP12.phx.gbl...
I有一个带有单个子表单的MDI表单。
I have an MDI form with a single child form.




您是否打开过多个子表单实例?如果没有,为什么要使用

MDI?



Do you ever open more than one instance of the child form? If not, why use
MDI at all?


我的客户要求我确定他们的production.Net MDI应用程序为什么

泄漏内存。我把它缩小到菜单项。我创建了一个

非常简单的MDI应用程序,只有一个子表单来重新创建泄漏。我可以

如果我愿意,可以提出多个子表单的实例,并且可能

泄漏更多的内存,但没有必要重现这个泄漏。


-Rich


" Jeff Johnson [MVP:VB]" <我*** @ enough.spam>在消息中写道

新闻:OX ************** @ TK2MSFTNGP09.phx.gbl ...
My client has asked me to determine why their production.Net MDI app is
leaking memory. I narrowed it down to the menu items. I have created a
very simple MDI app with a single child form to recreate the leak. I could
bring up more than one instance of the child form if I desired and probably
leak even more memory, but it wasn''t necessary to reproduce this leak.

-Rich

"Jeff Johnson [MVP: VB]" <i.***@enough.spam> wrote in message
news:OX**************@TK2MSFTNGP09.phx.gbl...

" ; Rich B. < RI ****** @ hotmail.com>在消息中写道
新闻:ug ************** @ TK2MSFTNGP12.phx.gbl ...

"Rich B." <ri******@hotmail.com> wrote in message
news:ug**************@TK2MSFTNGP12.phx.gbl...
我有一个MDI表格使用单个子表单。
I have an MDI form with a single child form.



您是否打开过多个子表单实例?如果没有,为什么要使用
MDI?



Do you ever open more than one instance of the child form? If not, why use
MDI at all?



Hi Rich,


通常没有任何理由可以处理一个mnu项目,因为

形式的内容是偶然的,每件事都应该由框架处理。


我从来没有在这个新闻组中看到这个问题(什么也没说什么可能

然而在谷歌搜索这个确实没有任何问题)


我知道这不是答案,只是一个意见,可以帮助你继续寻找问题。


Cor
Hi Rich,

Normally there should not be any reason to dispose a mnu item, because the
form inplements idisposable, every thing should be handled by the framework.

I never have seen this problem in this newsgroup (what says nothing maybe
however doing a search in google on this did as well give not any problem)

I know it is no answer, just an opinion, to help you going on in searching
for the problem.

Cor
我有一个带有单个子表单的MDI表单。我发现了一些似乎导致框架泄漏Int32s,
MenuItems,MenuItemCollections以及有时TRACKMOUSEEVENTs的情况。如果我禁用/启用menuitem,以编程方式添加新的menuitem或在mdiList菜单中单击
条目,则会发生这种情况。我正在处理子菜单中的主菜单以及主要的mdi形式,所以这不是问题。

我看过 http://support.microsoft.com/default...b;en -us; 817723
看起来是相同或密切相关的问题,但是微软说这个bug在.NET Framework的v1.1中得到修复
(这就是我正在使用的。)

使用SciTech的.NET Memory Profiler,似乎这些泄露的对象被保存在MenuItem的allCreatedMenuItems哈希表中。
我可以通过使用反射访问并清除MDI Dispose中的哈希表来解决这个问题,但是我的公司对这个解决方案并不满意。他们更喜欢基于Microsoft或推荐的解决方案。

这是框架中的已知错误,是否有一个修补程序,
有谁知道?有什么建议吗?

谢谢,
Rich
I have an MDI form with a single child form. I have found a couple of
circumstances that appear to cause the framework to leak Int32s, MenuItems, MenuItemCollections and sometimes TRACKMOUSEEVENTs. This happens if I
disable/enable a menuitem, add a new menuitem programatically or click on an entry in the mdiList menu. I am disposing the main menu in the child form
as well as in the main mdi form, so that''s not the issue.

I have seen http://support.microsoft.com/default...b;en-us;817723
which appears to be either the same or a closely related issue, but
Microsoft says that this bug was fixed in v1.1 of the .NET Framework (which is what I''m using).

Using the .NET Memory Profiler from SciTech it appears that these leaked
objects are being held in the allCreatedMenuItems hashtable in MenuItem. I can hack around this problem by using reflection to access and clear that
hashtable in the MDI Dispose, but my company isn''t comfortable with this
solution. They would prefer either a Microsoft based or recommended
solution.

Is this a know bug in the framework and is there a hotfix for it that anyone knows of? Any suggestions?

Thanks,
Rich



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

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