Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find a leak in User Objects

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

like image 335
Mitch Avatar asked Jun 03 '11 18:06

Mitch


1 Answers

if you know menus are hanging around you should be able to enumerate GDI objects for your process and nurf them with DeleteMenu().

windows should notify your parent window when popup menus are displayed and closed so that would be the perfect place to take snapshots of GDI menu handles and delete the newer one.

its pretty brute force and not recommended for .net where doing this sort of low-level GDI manipulation is perhaps naughty

i would make a simple test app with SyncFusion menus to prove the point and if the problem persists contact the vendor

like image 54
MickyD Avatar answered Oct 13 '22 20:10

MickyD