You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

16GB内存系统中占用1.3GB的.NET应用抛出OutOfMemoryException排查

64位.NET WinForms应用触发System.OutOfMemoryException的排查疑问

基础信息

  • 应用:Windows 10 64位.NET WinForms应用,以AnyCPU编译并关闭Prefer 32-bit选项,包含目标为x64的CLI/C++项目,无法在32位环境运行
  • 系统:16GB内存
  • 转储文件:大小1.3GB,经dotMemory分析,托管堆已分配220MB,其中108MB被占用;应用在其他场景下可正常占用超过1.3GB内存

异常堆栈

System.OutOfMemoryException: Out of memory.
at System.Drawing.Graphics.FromHdcInternal(IntPtr hdc)
at System.Drawing.Graphics.FromHdc(IntPtr hdc)
at DevExpress.XtraBars.Docking2010.DocumentsHost.DoPaint(Message& m)
at DevExpress.XtraBars.Docking2010.DocumentsHost.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

已完成的排查

  • 托管堆碎片:dotMemory的托管内存报告未发现异常
  • 内存区域状态:WinDbg执行!address -summary显示,进程内存大部分为保留(reserve)状态,提交(commit)仅1.25GB,具体输出如下:
    0:000> !address -summary
    --- Usage Summary ---------------- RgnCount ----------- Total Size -------- %ofBusy %ofTotal
    Free                                    405     7ffe`8db96000 ( 127.994 TB)          100.00%
    <unknown>                              1515        1`3f3b3000 (   4.988 GB)  86.22%    0.00%
    Image                                  2261        0`25f26000 ( 607.148 MB)  10.25%    0.00%
    Heap                                    120        0`08324000 ( 131.141 MB)   2.21%    0.00%
    Stack                                   234        0`04bc0000 (  75.750 MB)   1.28%    0.00%
    Other                                    39        0`00200000 (   2.000 MB)   0.03%    0.00%
    TEB                                      78        0`0009c000 ( 624.000 kB)   0.01%    0.00%
    PEB                                       1        0`00001000 (   4.000 kB)   0.00%    0.00%
    
    --- Type Summary (for busy) ------ RgnCount ----------- Total Size -------- %ofBusy %ofTotal
    MEM_PRIVATE                            1882        1`452fe000 (   5.081 GB)  87.82%    0.00%
    MEM_IMAGE                              2261        0`25f26000 ( 607.148 MB)  10.25%    0.00%
    MEM_MAPPED                              105        0`07236000 ( 114.211 MB)   1.93%    0.00%
    
    --- State Summary ---------------- RgnCount ----------- Total Size -------- %ofBusy %ofTotal
    MEM_FREE                                405     7ffe`8db96000 ( 127.994 TB)          100.00%
    MEM_RESERVE                             681        1`22426000 (   4.535 GB)  78.39%    0.00%
    MEM_COMMIT                             3567        0`50034000 (   1.250 GB)  21.61%    0.00%
    
    --- Protect Summary (for commit) - RgnCount ----------- Total Size -------- %ofBusy %ofTotal
    PAGE_READWRITE                         1835        0`23d12000 ( 573.070 MB)   9.67%    0.00%
    PAGE_EXECUTE_READ                       195        0`15090000 ( 336.563 MB)   5.68%    0.00%
    PAGE_READONLY                           854        0`13fde000 ( 319.867 MB)   5.40%    0.00%
    PAGE_WRITECOPY                          484        0`01633000 (  22.199 MB)   0.37%    0.00%
    PAGE_EXECUTE_READWRITE                   92        0`012db000 (  18.855 MB)   0.32%    0.00%
    PAGE_READWRITE|PAGE_WRITECOMBINE          5        0`00830000 (   8.188 MB)   0.14%    0.00%
    PAGE_READWRITE|PAGE_GUARD                78        0`0015e000 (   1.367 MB)   0.02%    0.00%
    PAGE_NOACCESS                            24        0`00018000 (  96.000 kB)   0.00%    0.00%
    
    --- Largest Region by Usage ----------- Base Address -------- Region Size ----------
    Free                                    213`79810000     7de1`2f130000 ( 125.880 TB)
    <unknown>                              7ff4`a8af0000        1`00020000 (   4.000 GB)
    Image                                  7ffd`06181000        0`03b43000 (  59.262 MB)
    Heap                                    213`6b332000        0`0095d000 (   9.363 MB)
    Stack                                    52`c8600000        0`000fb000 (1004.000 kB)
    Other                                   213`311e0000        0`00181000 (   1.504 MB)
    TEB                                      52`c8000000        0`00002000 (   8.000 kB)
    PEB                                      52`c8158000        0`00001000 (   4.000 kB)
    
  • GDI/用户句柄:已设置监控,当句柄数达到8000时触发告警,远低于系统10000的上限,未触发告警
  • Bitmap资源:对比正常与异常场景,Bitmap实例数量均约为1000个,未发现大量未释放的大Bitmap

疑问

目前无法解释为何16GB内存系统中,仅占用1.3GB内存的应用会抛出System.OutOfMemoryException,还有哪些可能的原因?是否为非托管内存碎片?该如何进一步排查?

内容的提问来源于stack exchange,提问作者Stijn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 19:35:18