Memory leak when calling AutomationElement::ElementFromPoint on Items View object


Symptoms


If an application requests many AutomationElements from an Items View, as described in the How to Query a Virtualized Item in Items View documentation, then the Items View may slow down and become non-responsive. For example, the Items View may scroll items more slowly or it may take longer to change column sizes.

Cause


When an AutomationElement is retrieved from an Items View it is never fully released. This causes updates to the state of the Items View to iterate through all of the previously queried AutomationElements.

Resolution


There is no way to recover the Items View short of exiting the process which owns the Items View.

Depending on the specific details of the automation application, it may be able to avoid the problem by requesting fewer AutomationElements (many operations which require that can be done via IFolderView2 instead) or by coercing the shell into using the Vista style ListView instead of the Items View (via IFolderViewOptions::SetFolderViewOptions(FVO_VISTALAYOUT,FVO_VISTALAYOUT).