惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 鞠强

HBase初探 C#访问Azure的资源 HDInsight - 1,简介 Windows8.1画热度图 - 坑 使用windbg查看DependencyObject的属性 LiveSDK初始化/登录时失败的解决办法 开发WP版本的大菠萝英雄榜 SQL 2014 in-memory中的storage部分 XAML绑定 Kinect 1 Diablo3狗熊榜 微软上海招聘有经验的.NET开发人员 塔防蜀的存档分析 我的HD2手机 和我一起作Tess的windbg lab,结束 和我一起作Tess的windbg lab - Lab6, MemoryLeak - 鞠强 和我一起作Tess的windbg lab - Lab5, Crash 和我一起作Tess的windbg lab - Lab4, High CPU 和我一起作Tess的windbg lab - Lab3, Memory
和我一起作Tess的windbg lab - Lab7, MemoryLeak
鞠强 · 2010-06-27 · via 博客园 - 鞠强

原文地址:http://blogs.msdn.com/b/tess/archive/2008/03/25/net-debugging-demos-lab-7-memory-leak.aspx

操作步骤:

1、产生压力:tinyget -srv:localhost -uri:/BuggyBits/News.aspx -threads:500 -loop:200

2、抓一个hang的dump,看看gc heap大小,!eeheap -gc,如下:

  GC Heap Size  0x1899f44c(412742732),大概400M,dump文件整个为550M。

3、看一下gc heap的总体状况:!dumpheap -stat,输出如下:

  7912d7c0     1342    400044140 System.Int32[]

  嗯,一共1300多个数组,但是这些数组居然占了400M,和gc heap的大小差不多。

4、察看一下详细情况,因为只有1300多个,所以我们可以全部打印出来:!dumpheap -mt 7912d7c0

5、几乎所有的数组,大小都是400K,随便找一个,然后找一下该数组的root,运行!gcroot 1f981e60,结果如下:

Scan Thread 49 OSTHread 2234
DOMAIN(00115B40):HANDLE(WeakLn):24b10dc:Root:02a621f4(System.Web.NativeFileChangeNotification)->
02a621d8(System.Web.DirMonCompletion)->
02a61ea4(System.Web.DirectoryMonitor)->
02a61ec8(System.Collections.Hashtable)->
02a61f00(System.Collections.Hashtable+bucket[])->
02a62100(System.Web.FileMonitor)->
02a62134(System.Collections.Specialized.HybridDictionary)->
02a62178(System.Collections.Specialized.ListDictionary)->
02a62194(System.Collections.Specialized.ListDictionary+DictionaryNode)->
02a5d538(System.Web.Compilation.BuildManager)->
02a5e0fc(System.Web.Compilation.MemoryBuildResultCache)->
02a2c970(System.Web.Caching.CacheSingle)->
02a2ca00(System.Web.Caching.CacheExpires)->
02a2ca20(System.Object[])->
02a2cd64(System.Web.Caching.ExpiresBucket)->
02b2e948(System.Web.Caching.ExpiresPage[])->
1b078ff0(System.Web.Caching.ExpiresEntry[])->
1b20583c(System.Web.Caching.CacheEntry)->
1b20581c(System.Web.Caching.CacheItemRemovedCallback)->
1b203db0(ASP.news_aspx)->
1f981e60(System.Int32[])
6、看其他的几个数组,引用顺序差不多。

7、猜测:代码中用了cache,cache中包含了一个400K的数组。但是由于某种原因,cache里面的东西没释放掉,越来越大。

8、查看源代码

    protected void Page_Load(object sender, EventArgs e)
    {
        string news = "<I>New site launched 2008-02-02</I>";
        string key = Guid.NewGuid().ToString();
        Cache.Add(key, news, null, Cache.NoAbsoluteExpiration, new TimeSpan(0, 5, 0), CacheItemPriority.NotRemovable, new CacheItemRemovedCallback(this.RemovedCallback));
        lblNews.Text = ((string)Cache[key]);
    }

  Cache有一个5分钟的失效期。但是由于我们的测试中,负载上来了,还没有到5分钟,所以看到的cache还在内存中。那么5分钟之后呢,可能会消失。但是更可能的是,在3分钟的时候,负载太大了,cache的东西又加上来了,最终导致OOM,程序挂了。

Over