7

Our .Net 4.0 application has a leak that causes it to crash after extended use. Upon investigation I determined that "User Objects" were leaking. A User object is a windows resource as described here:

http://msdn.microsoft.com/en-us/library/ms725486%28v=VS.85%29.aspx

Windows allocates 10,000 user objects per process. Other windows resources such as GDI objects and Handles are constant while the app is running.

I found a similar question for C++, where the solution required downloading a package called "detours" from microsoft reseach - the catch? $10K.

Using Ant memory profiler, I SUSPECT, it has to do with menus. We're using menus from SyncFusion, so the life cycle of stuff related to menus can not be found by looking in the code. So this may be a bug SynFusion must solve.

Anyone have a similar leak using SyncFusion menus? Ants tells me that some PopupMenu objects are sticking around, but Ants does not give info on how to find where the objects are created (and thus determine where to Dispose them).

The leakTrap/detours mentioned in the above referenced SO post looks interesting because it seemed to trap the specific calls to the USER object allocation.

Suggestions are welcomed

4

1 回答 1

1

如果你知道菜单在你身边,你应该能够为你的进程枚举 GDI 对象并用DeleteMenu () 来处理它们。

当弹出菜单显示和关闭时,windows 应该通知您的父窗口,这样将是拍摄 GDI 菜单句柄快照并删除较新菜单句柄的理想场所。

它相当蛮力,不推荐用于.net,在这种情况下进行这种低级 GDI 操作可能很顽皮

我会用 SyncFusion 菜单制作一个简单的测试应用程序来证明这一点,如果问题仍然存在,请联系供应商

于 2011-07-09T15:14:01.630 回答