1

I have a WPF window containing a Datagrid. Window starts in full-screen and the datagrid is populated. Then I Restore the window down and suddenly the process starts to require memory until it crashes. Taking snapshots of the memory before and after the resizing, I see that the memory is required by an increasingly number of object of type DataGridCellItemAutomationPeer and DataGridItemAutomationPeer.

User Gdir pointed out that I already reported a similar issue (WPF System.OutOfMemoryException System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree ), but it seems not to be the same case.

Weird enough, it seems to happen only on some machines, while I have at least one machine on which the problem does not arise.

digging deeper, it looks like method

protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer()

is called only on some machines. What is the discriminant that triggers the call to that method?

Any hint to guide me to solve the problem?

Thanks!

Community
  • 1
  • 1
Starnuto di topo
  • 3,215
  • 5
  • 32
  • 66
  • You reported a [similar problem](http://stackoverflow.com/questions/32483711/wpf-system-outofmemoryexception-system-windows-automation-peers-automationpeer-u) in Sep 2015. Is that related? – gdir Feb 20 '17 at 15:34
  • Thanks! I forgot that that post was mine. Anyway, it seems not to be the same case. I update my question to add more details. – Starnuto di topo Feb 21 '17 at 07:27

1 Answers1

0

(This is just a partial answer)

It turns out that fetching the DataGrid source code and removing the method

protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer()

from all DataGrid-related classes, the problem goes away. Suspect is that some bug in class DataGridAutomationPeer generates an infinite loop in some particular circumstances.

Still is unclear to me why OnCreateAutomationPeer is called and why the problem only occurs on some machines.

Starnuto di topo
  • 3,215
  • 5
  • 32
  • 66