dotnet: .NET 4.7 System.Windows.Forms.DataGridView.OnMouseWheel causes induced GC
Changes in System.Windows.Forms.Screen
in .NET 4.7 have caused the DataGridView
to trigger an induced GC on every mouse wheel event. Specifically, this stack trace ends in a call to GC.Collect
:
System.Internal.HandleCollector+HandleType.Add(IntPtr)
System.Windows.Forms.Internal.DeviceContext.FromCompatibleDC(IntPtr)
System.Windows.Forms.Internal.WindowsGraphics.CreateMeasurementWindowsGraphics(IntPtr)
System.Windows.Forms.Screen..ctor(IntPtr, IntPtr)
System.Windows.Forms.Screen.FromHandleInternal(IntPtr)
System.Windows.Forms.DataGridView.FlushDisplayedChanged
System.Windows.Forms.DataGridView.ScrollRowsByCount(Int32, ScrollEventType)
System.Windows.Forms.DataGridView.OnMouseWheel(MouseEventArgs)
System.Windows.Forms.Control.WmMouseWheel(Message&)
System.Windows.Forms.Control.WndProc(Message&)
System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr)
This makes scrolling a DataGridView
with the mouse wheel effectively unusable – the UI thread is blocked for 1-3 seconds every time you move the wheel.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 21 (9 by maintainers)
Official patches for Windows 10 creators Update that take care of the bug in Screen constructor are available here: http://www.catalog.update.microsoft.com/Search.aspx?q=KB4032188
@apwr Screen class constructor is fixed, thus all paths that invoke it should be taken care of. We are working on a hot fix, but don’t have release dates yet.
@gluck - thank you for verification. Update for Windows 7 and all other OSs will be available in the end of August.