huangxincheng

一:背景

1. 讲故事

上个月有位朋友加微信求助,说他的程序跑着跑着就内存爆掉了,寻求如何解决,截图如下:

从聊天内容看,这位朋友压力还是蛮大的,话说这貌似是我分析的第三个 MES 系统了,看样子 .NET 在传统工厂是巨无霸的存在哈。。。

话不多说,一起用 Windbg 一探究竟吧。

二:Windbg 分析

1. 托管还是非托管

先看下进程的commit内存,用 !address -summary 即可。


0:000> !address -summary

                                     
Mapping file section regions...
Mapping module regions...
Mapping PEB regions...
Mapping TEB and stack regions...
Mapping heap regions...
Mapping page heap regions...
Mapping other regions...
Mapping stack trace database regions...
Mapping activation context regions...

--- Type Summary (for busy) ------ RgnCount ----------- Total Size -------- %ofBusy %ofTotal
MEM_PRIVATE                             971          e7d6b000 (   3.622 GB)  95.24%   90.56%
MEM_IMAGE                              1175           ac5d000 ( 172.363 MB)   4.43%    4.21%
MEM_MAPPED                               34            d08000 (  13.031 MB)   0.33%    0.32%

--- State Summary ---------------- RgnCount ----------- Total Size -------- %ofBusy %ofTotal
MEM_COMMIT                             1806          edfd9000 (   3.719 GB)  97.77%   92.97%
MEM_FREE                                190           c920000 ( 201.125 MB)            4.91%
MEM_RESERVE                             374           56f7000 (  86.965 MB)   2.23%    2.12%

...

可以看到,当前占用内存是 3.79G,从内存地址看是一个 32bit 程序,看样子程序在崩溃的边缘哈

相关文章: