This project is read-only.


Search for event subscribers and unsubscribers for one or more events. There is a special switch -imbalance to search for classes where an event is more often subscribed than unsubscribed. This helps to track down memory leaks caused by forgotten unregister calls to an event. Although the heuristic is very simple it does help a lot when there is already a large existing code base.


-WhousesEvent <typeeventquery> <defining event file/s> -in <using file/s> [-imbalance]
-we <typeeventquery> <defining event file/s> -in <using file/s> [-imbalance]


The following query does search for all public types all public events from the Windows.Forms assembly and checks which classes from the
.NET Framework have imbalanced event subscriptions.

ApiChange -whousesevent "public *(public event * *)" GAC:\System.Windows.Forms.dll -in $net2 -excel -imbalance

The output below shows many event "leaks" which are not the cause of memory leaks since in Windows forms applications the lifetime of the event subscribers is usually the same as of the form itself. It is therefore not necessary to unregister these events. But for other event sources this might not be the case.

Excel output

Last edited Jun 4, 2010 at 4:42 PM by Alois, version 3


No comments yet.