簡體   English   中英

自Windows 10 1709更新以來-System.OutOfMemoryException c#.net

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

我的winforms應用程序一直運行良好,直到最新的Windows 10 1709更新為止,此后更新運行我的應用程序在運行獨立的.exe或Visual Studio 2017時不斷崩潰。該應用程序在具有最新1709更新的任何計算機上崩潰。 作為測試,我創建了一台Windows 7計算機,並且可以完美運行,並且Windows 10 1709之前的所有版本都可以正常運行。

當我得到System.OutOfMemoryException異常時,它是相當隨機的;但是通常在System.Form.Timer觸發或運行線程時(這可能是一個提示!)。

可以肯定的是,我沒有記憶力不足! (32GB,其中50%可用在我的開發機器上)。

我很茫然是什么原因造成的,並嘗試了以下方法:

該解決方案包含大約30個C#項目。 -我已從.Net 4.6更新到4.6.1,然后又更新到4.7和4.7.1-更新了所有Nuget項目。 -在Windows 7上編譯的代碼在Windows 10上運行(崩潰)-在Windows 7上運行良好。-在Windows 10 Home,Windows 10 Pro(1709)上運行。 在較舊的Windows 10上運行良好! -全新安裝具有32GB RAM的Windows 10 Pro(我的開發機)。 -禁用計時器和線程(僅在其他位置獲得異常)。

回滾OS並不是一個解決方案,因為我的用戶依賴運行Windows 10的該軟件。上周,我一直在尋找此解決方案,但沒有解決方案,希望我能得到一些好的指導以最終解決此問題。

以下是兩個回溯-自從我更新到最新的1709以來,我有100個此類回溯(通過rollbar.com):

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.

原來實際的問題是.Net WebBrowser控件,這導致使用大量內存。.我同時打開了許多Fice WebBrowser控件..會吃掉2GB的RAM! (如果x32編譯的應用程序沒有崩潰,則x64的使用時間會更長!)。

刪除它們,應用程序僅再次消耗25MB!

ps切換到CefSharp,看看效果是否更好!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM