简体   繁体   中英

Since Windows 10 1709 Update - System.OutOfMemoryException c# .net

My winforms application has been running perfectly until the latest Windows 10 1709 Update and ever since updating my app crashes constantly when running the standalone .exe or in Visual Studio 2017. The app crashses on any machine with the latest 1709 update. As a test, I created a Windows 7 machine and works perfectly and all versions prior to Windows 10 1709 fine.

Its pretty random when I get System.OutOfMemoryException exception = usually however when System.Form.Timer fires or a thread is run (this may be aa clue!).

One thing for sure, I am not out of memory! (32GB with 50% available on my development machine).

I am at a loss what is causing this and have tried the following:

The solution comprises of around 30 C# projects. -I have updated from .Net 4.6 to 4.6.1 then to 4.7 and 4.7.1 -Updated all Nuget projects. -Compiled code on Windows 7, ran on Windows 10 (crashes) - it runs fine on Windows 7. - Ran on Windows 10 Home, Windows 10 Pro (1709). Works fine on older Windows 10! - Fresh install of Windows 10 Pro with 32GB of RAM (my development machine). - Disabled timers and threads (only to get exceptions elsewhere).

Roll back the OS is not a solution as I have users that rely on this software running Windows 10. I have been looking at this for the last week without no resolution and hope I can get some good pointers to finally resolve this.

Below are two tracebacks - I have 100s of these tracebacks (via rollbar.com) since I updated to latest 1709:

Traceback (most recent call last):
1
at Winforms.Components.ApplicationIdle.System.Windows.Forms.IMessageFilter.PreFilterMessage(System.Windows.Forms.Message& m) in "Winforms.Components.ApplicationIdle" line 17
2
at System.Windows.Forms.Application+ThreadContext.ProcessFilters(System.Windows.Forms.NativeMethods+MSG& msg, System.Boolean& modified) in "System.Windows.Forms.Application+ThreadContext" line 188
3
at System.Windows.Forms.Application+ThreadContext.PreTranslateMessage(System.Windows.Forms.NativeMethods+MSG& msg) in "System.Windows.Forms.Application+ThreadContext" line 2
4
at System.Windows.Forms.Application+ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FPreTranslateMessage(System.Windows.Forms.NativeMethods+MSG& msg) in "System.Windows.Forms.Application+ThreadContext" line 0
5
at System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, System.Int32 reason, System.Int32 pvLoopData) in "System.Windows.Forms.Application+ComponentManager" line 349
6
at System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(System.Int32 reason, System.Windows.Forms.ApplicationContext context) in "System.Windows.Forms.Application+ThreadContext" line 484
7
at System.Windows.Forms.Application+ThreadContext.RunMessageLoop(System.Int32 reason, System.Windows.Forms.ApplicationContext context) in "System.Windows.Forms.Application+ThreadContext" line 20
8
at System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm) in "System.Windows.Forms.Application" line 12
9
at CRS.Program.Main() in "CRS.Program" line 456
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.



at System.Windows.Forms.Internal.WindowsGraphics.FromHdc(System.IntPtr hDc) in "System.Windows.Forms.Internal.WindowsGraphics" line 7
2
at System.Windows.Forms.Internal.WindowsGraphics.FromGraphics(System.Drawing.Graphics g, System.Windows.Forms.Internal.ApplyGraphicsProperties properties) in "System.Windows.Forms.Internal.WindowsGraphics" line 114
3
at System.Windows.Forms.WindowsGraphicsWrapper..ctor(System.Drawing.IDeviceContext idc, System.Windows.Forms.TextFormatFlags flags) in "System.Windows.Forms.WindowsGraphicsWrapper" line 45
4
at System.Windows.Forms.VisualStyles.VisualStyleRenderer.GetPartSize(System.Drawing.IDeviceContext dc, System.Windows.Forms.VisualStyles.ThemeSizeType type, System.IntPtr hWnd) in "System.Windows.Forms.VisualStyles.VisualStyleRenderer" line 58
5
at System.Windows.Forms.RadioButtonRenderer.GetGlyphSize(System.Drawing.Graphics g, System.Windows.Forms.VisualStyles.RadioButtonState state, System.IntPtr hWnd) in "System.Windows.Forms.RadioButtonRenderer" line 13
6
at System.Windows.Forms.ButtonInternal.RadioButtonStandardAdapter.Layout(System.Windows.Forms.PaintEventArgs e) in "System.Windows.Forms.ButtonInternal.RadioButtonStandardAdapter" line 35
7
at System.Windows.Forms.ButtonInternal.CheckableControlBaseAdapter.GetPreferredSizeCore(System.Drawing.Size proposedSize) in "System.Windows.Forms.ButtonInternal.CheckableControlBaseAdapter" line 44
8
at System.Windows.Forms.ButtonBase.GetPreferredSizeCore(System.Drawing.Size proposedConstraints) in "System.Windows.Forms.ButtonBase" line 0
9
at System.Windows.Forms.RadioButton.GetPreferredSizeCore(System.Drawing.Size proposedConstraints) in "System.Windows.Forms.RadioButton" line 9
10
at System.Windows.Forms.Control.GetPreferredSize(System.Drawing.Size proposedSize) in "System.Windows.Forms.Control" line 90
11
at System.Windows.Forms.ButtonBase.GetPreferredSize(System.Drawing.Size proposedSize) in "System.Windows.Forms.ButtonBase" line 36
12
at System.Windows.Forms.Layout.DefaultLayout.LayoutAutoSizedControls(System.Windows.Forms.Layout.IArrangedElement container) in "System.Windows.Forms.Layout.DefaultLayout" line 106
13
at System.Windows.Forms.Layout.DefaultLayout.xLayout(System.Windows.Forms.Layout.IArrangedElement container, System.Boolean measureOnly, System.Drawing.Size& preferredSize) in "System.Windows.Forms.Layout.DefaultLayout" line 0
14
at System.Windows.Forms.Layout.DefaultLayout.LayoutCore(System.Windows.Forms.Layout.IArrangedElement container, System.Windows.Forms.LayoutEventArgs args) in "System.Windows.Forms.Layout.DefaultLayout" line 0
15
at System.Windows.Forms.Layout.LayoutEngine.Layout(System.Object container, System.Windows.Forms.LayoutEventArgs layoutEventArgs) in "System.Windows.Forms.Layout.LayoutEngine" line 0
16
at System.Windows.Forms.Control.OnLayout(System.Windows.Forms.LayoutEventArgs levent) in "System.Windows.Forms.Control" line 47
17
at System.Windows.Forms.Control.PerformLayout(System.Windows.Forms.LayoutEventArgs args) in "System.Windows.Forms.Control" line 105
18
at System.Windows.Forms.Control.System.Windows.Forms.Layout.IArrangedElement.PerformLayout(System.Windows.Forms.Layout.IArrangedElement affectedElement, System.String affectedProperty) in "System.Windows.Forms.Control" line 8
19
at System.Windows.Forms.Control.Scale(System.Drawing.SizeF includedFactor, System.Drawing.SizeF excludedFactor, System.Windows.Forms.Control requestingControl) in "System.Windows.Forms.Control" line 44
20
at System.Windows.Forms.Control.ScaleChildControls(System.Drawing.SizeF includedFactor, System.Drawing.SizeF excludedFactor, System.Windows.Forms.Control requestingControl) in "System.Windows.Forms.Control" line 45
21
at System.Windows.Forms.Control.Scale(System.Drawing.SizeF includedFactor, System.Drawing.SizeF excludedFactor, System.Windows.Forms.Control requestingControl) in "System.Windows.Forms.Control" line 23
22
at System.Windows.Forms.Control.ScaleChildControls(System.Drawing.SizeF includedFactor, System.Drawing.SizeF excludedFactor, System.Windows.Forms.Control requestingControl) in "System.Windows.Forms.Control" line 45
23
at System.Windows.Forms.Control.Scale(System.Drawing.SizeF includedFactor, System.Drawing.SizeF excludedFactor, System.Windows.Forms.Control requestingControl) in "System.Windows.Forms.Control" line 23
24
at System.Windows.Forms.Control.ScaleChildControls(System.Drawing.SizeF includedFactor, System.Drawing.SizeF excludedFactor, System.Windows.Forms.Control requestingControl) in "System.Windows.Forms.Control" line 45
25
at System.Windows.Forms.Control.Scale(System.Drawing.SizeF includedFactor, System.Drawing.SizeF excludedFactor, System.Windows.Forms.Control requestingControl) in "System.Windows.Forms.Control" line 23
26
at System.Windows.Forms.Control.ScaleChildControls(System.Drawing.SizeF includedFactor, System.Drawing.SizeF excludedFactor, System.Windows.Forms.Control requestingControl) in "System.Windows.Forms.Control" line 45
27
at System.Windows.Forms.Control.Scale(System.Drawing.SizeF includedFactor, System.Drawing.SizeF excludedFactor, System.Windows.Forms.Control requestingControl) in "System.Windows.Forms.Control" line 23
28
at System.Windows.Forms.Control.ScaleChildControls(System.Drawing.SizeF includedFactor, System.Drawing.SizeF excludedFactor, System.Windows.Forms.Control requestingControl) in "System.Windows.Forms.Control" line 45
29
at System.Windows.Forms.Control.Scale(System.Drawing.SizeF includedFactor, System.Drawing.SizeF excludedFactor, System.Windows.Forms.Control requestingControl) in "System.Windows.Forms.Control" line 23
30
at System.Windows.Forms.ContainerControl.OnChildLayoutResuming(System.Windows.Forms.Control child, System.Boolean performLayout) in "System.Windows.Forms.ContainerControl" line 81
31
at System.Windows.Forms.Control.OnChildLayoutResuming(System.Windows.Forms.Control child, System.Boolean performLayout) in "System.Windows.Forms.Control" line 0
32
at System.Windows.Forms.Control.OnChildLayoutResuming(System.Windows.Forms.Control child, System.Boolean performLayout) in "System.Windows.Forms.Control" line 0
33
at System.Windows.Forms.Control.OnLayoutResuming(System.Boolean performLayout) in "System.Windows.Forms.Control" line 8
34
at System.Windows.Forms.Control.ResumeLayout(System.Boolean performLayout) in "System.Windows.Forms.Control" line 35
35
at CRS.Dialogs.frmCheckin.InitializeComponent() in "CRS.Dialogs.frmCheckin" line 75929
36
at CRS.Dialogs.frmCheckin..ctor() in "CRS.Dialogs.frmCheckin" line 298
37
at CRS.Dialogs.OpenTicketHelper.OpenTicket() in "CRS.Dialogs.OpenTicketHelper" line 12
38
at CRS.Dialogs.frmTicketTracker.btnNewCheckin_Click(System.Object sender, System.EventArgs e) in "CRS.Dialogs.frmTicketTracker" line 19
39
at System.Windows.Forms.Control.OnClick(System.EventArgs e) in "System.Windows.Forms.Control" line 25
40
at System.Windows.Forms.Button.OnClick(System.EventArgs e) in "System.Windows.Forms.Button" line 46
41
at System.Windows.Forms.Button.OnMouseUp(System.Windows.Forms.MouseEventArgs mevent) in "System.Windows.Forms.Button" line 119
42
at System.Windows.Forms.Control.WmMouseUp(System.Windows.Forms.Message& m, System.Windows.Forms.MouseButtons button, System.Int32 clicks) in "System.Windows.Forms.Control" line 388
43
at System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message& m) in "System.Windows.Forms.Control" line 1647
44
at System.Windows.Forms.ButtonBase.WndProc(System.Windows.Forms.Message& m) in "System.Windows.Forms.ButtonBase" line 0
45
at System.Windows.Forms.Button.WndProc(System.Windows.Forms.Message& m) in "System.Windows.Forms.Button" line 61
46
at System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message& m) in "System.Windows.Forms.Control+ControlNativeWindow" line 0
47
at System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message& m) in "System.Windows.Forms.Control+ControlNativeWindow" line 142
48
at System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, System.Int32 msg, System.IntPtr wparam, System.IntPtr lparam) in "System.Windows.Forms.NativeWindow" line 37
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.

Its turned out the actual issue was .Net WebBrowser Control that was causing massive amount of memory to be used.. I had fice WebBrowser controls open at the same time.. would eat 2GB of RAM! (more if the x32 compiled app didnt crash, x64 lasted much longer!).

Removed them, app only consumes 25MB again!

ps changing over to CefSharp to see if this fares better!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM