大对象堆碎片:CLR有什么解决办法吗? [英] Large Object Heap fragmentation: CLR has any solution to it?

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

问题描述

如果您的应用程序必须对大尺寸对象(>85000 字节)进行大量分配/取消分配,最终会导致内存碎片,您的应用程序将抛出内存不足异常.

If you application is such that it has to do lot of allocation/de-allocation of large size objects (>85000 Bytes), its eventually will cause memory fragmentation and you application will throw an Out of memory exception.

这个问题有什么解决办法还是CLR内存管理的限制?

Is there any solution to this problem or is it a limitation of CLR memory management?

推荐答案

不幸的是,我所看到的所有信息都只建议自己管理风险因素:重用大对象,在开始时分配它们,确保它们是如果大小是彼此的倍数,则使用替代数据结构(列表、树)而不是数组.这只是给了我另一个想法,即创建一个非分段列表,而不是一个大数组,而是拆分成更小的数组.数组/列表似乎是 IME 最常见的罪魁祸首.

Unfortunately, all the info I've ever seen only suggests managing risk factors yourself: reuse large objects, allocate them at the beginning, make sure they're of sizes that are multiples of each other, use alternative data structures (lists, trees) instead of arrays. That just gave me an another idea of creating a non-fragmenting List that instead of one large array, splits into smaller ones. Arrays / Lists seem to be the most frequent culprits IME.

这是一篇关于它的 MSDN 杂志文章:http://msdn.microsoft.com/en-us/magazine/cc534993.aspx,但它并没有那么多用处.

Here's an MSDN magazine article about it: http://msdn.microsoft.com/en-us/magazine/cc534993.aspx, but there isn't that much useful in it.

这篇关于大对象堆碎片:CLR有什么解决办法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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