- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我广泛使用基于并行数组( SCG.SortedList<K,V>
,看起来像 Outer<K, Inner<K_delta,V>>
)的嵌套数据结构和大量复制结构的计算引擎。结构的大小可能非常不同,其中许多结构将位于 LOH 中,因为 - 即使它们已经嵌套 - 内部结构或外部结构都足够长,并且值大多为 double (对于 double ,限制为 1000 个元素每个数组,然后它进入 LOH,至少在 x86 上)。
嵌套数据结构的用例是在长时间运行的进程中积累高频数据。我可以使用它作为缓冲区来聚合数据,并仅保留聚合所需的最小窗口(通过删除旧的内部列表并修剪外部列表),但是这种复制/修剪本身可能会产生 LOH 碎片问题并占用更多内存,而不是保存它。
在深入了解 LOH 碎片之后,我可以推断在我的情况下,我将会遇到 LOH 碎片,因为在我的流程/计算中经常发生的情况正是 great article about LOH fragmentation by Andrew Hunter 中所描述的:创建、随机增量增长、复制数组...
但是,我无法理解 64 位平台上的 LOH 碎片是否是一个问题?在同一篇文章的最后评论中,评论者认为在 64 位平台上,LOH 碎片几乎是一个问题。这不是问题,因为地址空间太大,实际上很难耗尽它,而内存空洞/空页不受实际内存的支持。 (另一种选择是 MS 在设计 GC 时严重失败)。
请专家确认一下评论中的说法对于 .NET 托管内存是否正确? 64 位系统上的 LOH 碎片是否真的不值得担心?在大多数情况下,由于地址空间非常大?在编写这个问题时,我发现了 a confirmation for C++ ,所以这个问题专门针对 .NET 中的托管内存。
第二个问题是它如何适用于在 64 位系统上运行的 32 位进程?这是否同样适用于两者,或者如果存在 LOH 碎片,32 位进程可能会很快耗尽内存? (例如,对于 Excel 加载项,即使在 64 位系统上,由于存在遗留加载项,我在很长一段时间内也仅限于 32 位架构)
链接文章的评论如下:
Page CachePosted by: TruePathPosted on: Thursday, November 24, 2011 at 6:50 AMMessage:
Either you are using an oldOS/cpu that doesn't support 64 bit addressing (or a cheap version ofwin 7) or MS has radically failed to take proper advantage of 64 bitaddressing.
Win 7 ultimate lets a process address up to 192 gigs, snow leopard16TB and linux 32 exabytes. You are never going to realistically chewthrough that entire address space in the LOH. Thus the strategy thatMS implemented for allocation sounds like the right one and it's onlysome artificial limit that is getting in the way.
Remember just because you've allocated a page of memory doesn't meanthe OS has to always back that up with a page of RAM. The OS isperfectly free to swap pages out to disk or leave blank pagesunbacked. The LOH should be allocating an integer number of psges (4K)for each object. When an object in the LOH is freed by the GC thepages allocated to it should be returned to the OS so they no longerneed any backing store and don't take up disk space or strain the pageallocation structures.
Indeed, the LOH on a 64 byte system should be substantially faster andless resource intensive than the normsl heaps since no objects areever copied and all objects get an integer number of pages. Unlike theregulsr heap fragmentation isn't really an issue since this getshandled for you by the hardware supported page tables. Indeed it mightbe optimal to never GC the LOH until virtual memory limits are hit.
True such a strategy would end up writing huge parts of your LOH outto disk but that happens in a second concurrent process. As long asyou aren't allocating objects in the LOH and dirtying their pagesfaster than your disk can write them you shouldn't see any slowdownexcept a minor competion for disk IO and a small impact of larger OSpage maps. The system won't thrash because most of those pages reallyare free and thus are never again read back from disk. Without a GCmarking objects in the LOH no false page access by the GC occurs. Thusthe LIFO algorithm employed by the page cache is a pretty decent GCthat trades GC overhead for some disk writes and (maybe) an occasionalread.
I guess it would be superior to hold the GC metadata and any embeddedpointers for objects in the LOH on a separate page from the rest ofthe data (it can precede it if you want and the rest of the page canbe used for other heaps/metadata) so the GC can still free the pagesin the LOH without triggering any unneeded page loads. Since objectsin the LOH have few if any pointer members/elements (or are allpointers and must be scanned by the GC anyway) one can segregate thosefrom the data and get the best of both worlds: no disk writes and nofalse page loads for the GC.
更新:假设存在 LOH 碎片。问题是关于内存地址空间碎片对 x64 平台上实际内存的影响,以及它在 x64 上运行的 32 位进程中如何工作。
问题不在于如何避免/处理它以及使用什么数据结构(本文讨论了这一点)。我做了很多测试,发现嵌套排序列表比不可变结构快 5 倍以上,并且通过在内部列表中使用键增量(uint16 与 int64)将我的数据压缩 c.40%,而 IntMap/AVL 树每个键/值对需要 70/50 字节的开销。对于非常现实的 1000 万对,我更喜欢嵌套 SL。因此,预期/可能的 LOH 碎片是速度和简单内存压缩所付出的代价。我无法全面测试有多少内存由于碎片而实际“泄漏”,但从我所读到的内容来看,我有理由怀疑是否存在任何泄漏。
最佳答案
CLR 中的垃圾收集器部分没有不好的设计。问题是,为了对 LOH 进行碎片整理,您需要腾出空间,然后重新排序并压缩对象。对于大型对象,重新排序可能会移动多个大型对象,而内存增益却很小(例如,如果您有 100 个对象,每个对象大小为 0.5MB,则可能需要复制并重新排序 200MB 内存才能压缩此对象)内存空间。这个现象有一个很好的解释 at this link
64 位 CLR 具有相同的 LOH 大小阈值(因为这是根据实际应用程序选择的),并且它不会比 32 位 CLR 中的问题更大。如果您迁移到 .Net 4.0+,将会有所帮助,该版本对 LOH 算法进行了改进,以防止内存不足并提高堆栈中漏洞的重用。 .Net 4.5 甚至还压缩了 LOH LOH compaction MSDN这将消除处理大型数组的自定义应用程序的大多数问题。
由于地址空间的大小,使用 64 位将具有优势。然而,这些讨论都不会否定软件的质量设计。垃圾收集器是应用程序运行缓慢的原因之一。您应该检查一下您的算法和数据结构,以确保您获得所需的效率提升。如果您正在接近应用程序的极限并且发现碎片问题,也许您应该研究使用数组以外的集合和/或限制数组的大小,以便它们不会分配在 LOH 上。
测量然后优化:)
关于c# - 与 .NET 上的 32 位平台相比,64 位平台上的大对象堆碎片是否是一个问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21036376/
我在 cordova@7.1.0、cordova-ios@4.5.2 下运行。安装平台:ios 4.5.2。 我运行 npm install、bower install,然后运行 cordova
我正在使用 VSTS 构建 IOS,运行命令后出现以下错误:cordova build ios 平台“android”似乎不是有效的 cordova 平台。它缺少 API.js。不支持安卓。 Cord
您使用什么软件/Wiki 来编写和分享有关开发人员、测试人员和管理人员的规范? 你使用维基系统,如果是,你使用什么维基软件? 或者您是否使用 Sharepoint 来管理和版本规范?将 SharePo
这是一家销售完整软件套件/平台的公司的示例 www.ql2.com/technology/platform.php 我想知道这样的套件/平台是如何开发的?你必须使用J2EE吗? 我更感兴趣的是这家公司
这个问题不太可能对任何 future 的访客有帮助;它只与一个较小的地理区域、一个特定的时间点或一个非常狭窄的情况相关,通常不适用于全世界的互联网受众。如需帮助使此问题更广泛适用,visit the
我有一个连接到套接字连接的应用程序,并且该连接向我发送了很多信息..可以说每秒 300 个订单(也许更多)..我有一个类(它就像一个监听器,对某个事件(并且该事件具有顺序)接收该顺序。创建一个对象,然
我即将开始一个 Netbeans 平台的项目。有没有人推荐他们用过并觉得有用的书籍或教程? 编辑: 这是一个已经开发好的swing应用。 最佳答案 除了 NetBeans 网站上的教程外,我还喜欢这本
有没有什么好的方法可以以非特定语言的方式定义接口(interface)/类层次结构,然后以特定语言生成相应的源代码?特别是,我需要同时针对 Java 和 C# 来创建一个相当全面的 API。我记得有一
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 8 年前。 Improve
大家晚上好我使用 API 平台,我想在创建实体时自动将所有者添加到我的实体中。我创建了一个事件来覆盖 API 平台,它获取当前用户并添加它。但是我的事件永远不会发生,但它确实存在于 debug:eve
这是一个有点奇怪的元编程问题,但我意识到我的新项目不需要完整的 MVC 框架,作为一个 Rails 人,我不确定现在该使用什么。 为您提供必要功能的要点;该网站将显示静态页面,但用户将能够登录并“编辑
这两天我的信息有点过载。 我打算建立自己的网站,允许本地企业列出他们的打折商品,然后用户可以进来搜索“Abercrombie T 恤”,然后就会列出出售它们的商店。 这是一个非常棒的小项目,我真的很兴
我的任务是为产品的下一代版本评估“企业”平台。我们目前正在考虑两种“类型”的平台——RAD(工作流引擎、集成 UI、工作流“技术插件”的小核心、状态的自动持久化……),例如 SalesForce.co
我需要一个不依赖于特定语言或构建系统的依赖管理器。我研究了几个优秀的工具(Gradle、Bazel、Hunter、Biicode、Conan 等),但没有一个能满足我的要求(见下文)。我还使用了 Gi
我在 Symfony 4 Flex 应用程序中使用 API Platform v2.2.5,该应用程序由一个功能 API 和 JWT Authentication 组成。 ,一些资源默认Open AP
虽然隐私法通常不属于我们开发人员的管辖范围,但我确实认为这是一个重要的话题,因为我们开发人员应该有责任警告我们的雇主,如果他们想要的东西会违反一些法律......在这种情况下,隐私法......通常情
我已经下载了 VisualVM 源代码,并尝试使用 Netbeans 7.01 编译 Glassfish 插件。这样做会导致以下错误: C:\source\visualvm\trunk\plugins
尝试 gradle 同步后...失败并在消息对话框中显示 Missing Android platform(s) detected: 'android-26' Install missing plat
大家好!我最近开始使用 Cordova,当我运行 Cordova platform add android 时,出现以下错误。我已经成功放置了 Java 和 Android SDK 的环境变量。但 n
已关闭。这个问题是 off-topic 。目前不接受答案。 想要改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 已关闭10 年前。 Improve th
我是一名优秀的程序员,十分优秀!