Server 2008上的堆碎片 [英] Heap Fragmentation on Server 2008

查看:94
本文介绍了Server 2008上的堆碎片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到一份关于某个应用程序的报告,该应用程序在Server  2008上显示了私有字节内存增长。 这个过程大量使用COM,因此会进行大量的内存分配! 这个装置的独特之处在于他们升级了硬件
&操作系统并没有在Server 2003上看到这种内存增长。


我得到了他们的配置并在Server 2008上运行了测试,建立了一个基线,通过该过程运行一组消息,然后检查内存增长。 私有字节显示从基线增加了18 MB,而VMMap也显示堆增长了18 MB也是b $ b。 没问题,我会用UMDH来寻找泄漏。 在5天内,我查找了具有相同配置和相同测试消息的泄漏,但找不到任何内容。 我会看到堆使用量增加800 K或下降相同的数量,但没有
可以解释我在没有这个堆调试的情况下运行时看到的18 MB。


我担心堆碎片是我的问题,并开始研究可以做些什么。我发现了低碎片堆(在Server 2003上可用,但默认情况下不可用),这是Server 2008的默认堆。


出于绝望,我决定尝试禁用LFH看看堆增长是否会停止。 我发现你不能从你的进程内部做到这一点,一旦进程堆是LFH就无法关闭它。  KB929136说某些堆调试标志将
禁用LFH。 我选择了"堆标记"。 (gflags / i myprocess.exe + htg)。 我验证了!heap -s,当进程启动时,LFH被禁用。


当我使用此标志集运行测试时,我看到基线处的初始专用字节使用率较低(这使得感觉,LFH分配有更多的开销),并且在测试结束时私有字节没有变化。 这对我来说是令人震惊的,读取有关LFH的
,它似乎是为像我这样的COM应用程序量身定做的。


我的问题是,是否可以在Server 2008上运行与"旧"堆&NBSP?;使用堆标记运行似乎运行时调试堆非常慢,速度慢4倍到5倍,就像在执行UMDH分析时运行+ ust一样。 通过图像执行选项或应用程序兼容性填充程序在Server 2008上使用与Server 2003相同的堆运行是否可能


谢谢!

解决方案

您似乎想要禁用LFH。不建议这样做。我们强烈反对在一个过程中禁用LFH,因为你不太可能最终处于比LFH更好的状态。 LFH确实有一些开销,但启用LFH后性能
更好。


1。无论是否启用LFH,系统都不会将LFH用于大于16 KB的分配( http://msdn.microsoft.com/en-us/library/aa366750(v = vs.85).aspx )。

2. LFH不能可以使用HEAP_NO_SERIALIZE创建的堆或者使用固定大小创建的堆来启用。
3.可以使用带有HeapCompatibilityInformation类的HeapSetInformation API禁用LFH,但不建议再次禁用LFH。


I received a report about an application that was showing private bytes memory growth on Server 2008.  This process heavily uses COM, therefore does lots of memory allocation!  What is unique about this installation is that they upgraded hardware & OS and didn't see this memory growth on Server 2003.

I got their configuration and ran a test on Server 2008, estabilishing a baseline, running a set of messages though the process, then checking the memory growth.  Private bytes showed 18 MB of growth from the baseline and VMMap showed the heap grew by 18 MB also.  No problem, I'll use UMDH to look for a leak.  For 5 days I looked for a leak with the same configuration and same test messages and couldn't find anything.  I'd see heap usage grow by 800 K or drop by the same amount, but nothing could explain the 18 MB I saw when running without this heap debugging.

I feared heap fragmentation was my problem and started researching what could be done about it. I found out about the low fragmentation heap (available on Server 2003, but not by default) and that this was the default heap for Server 2008.

Out of desperation I decided to try to disable the LFH to see if the heap growth would stop.  I found you can't do it from inside your process, once the process heap is LFH it can't be turned off.  KB929136 says certain heap debugging flags will disable the LFH.  I settled on "heap tagging" (gflags /i myprocess.exe +htg).  I verified with !heap -s that when the process started that LFH was disabled.

When I ran my test with this flag set I saw lower initial private bytes usage at the baseline (which makes sense, the LFH allocations have more overhead), and at the end of the test the private bytes was unchanged.  This was shocking to me, reading about the LFH, it seemed to be tailored for a COM application like mine.

My question is, is it possible on Server 2008 to run with the "old" heap?  Running with heap tagging on seemed to run with a debug heap that was very slow, 4x to 5x slower, much like when running with +ust when doing the UMDH analysis.  Is it possible on Server 2008 through an image execution option or an application compatibility shim to run with the same heap that Server 2003 had?

Thanks!

解决方案

It seems you would like to Disable LFH. This is not recommended. We would strongly discourage from disabling LFH within a process as it is highly unlikely you will end up in a better situation than you would with LFH. LFH does has some overhead but performance is better with LFH enabled.

1. The system does not use the LFH for allocations larger than 16 KB, whether or not the LFH is enabled (http://msdn.microsoft.com/en-us/library/aa366750(v=vs.85).aspx).
2. The LFH cannot be enabled for heaps created with HEAP_NO_SERIALIZE or for heaps created with a fixed size
3. The LFH can be disabled by using the HeapSetInformation API with the HeapCompatibilityInformation class, but again disabling LFH is not recommended.


这篇关于Server 2008上的堆碎片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆