64 位空间中的堆碎片 [英] Heap fragmentation in 64 bit land

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

问题描述

过去,当我处理长时间运行的 C++ 守护进程时,我不得不处理堆碎片问题.为了避免连续堆空间耗尽,必须使用诸如保留大量分配池之类的技巧.

In the past, when I've worked on long-running C++ daemons I've had to deal with heap fragmentation issues. Tricks like keeping a pool of my large allocations were necessary to keep from running out of contiguous heap space.

这仍然是 64 位地址空间的问题吗?Perf 对我来说不是问题,所以我更愿意简化我的代码,不再处理诸如缓冲池之类的事情.有没有人有任何关于这个问题的经验或故事?我使用的是 Linux,但我想许多相同的问题也适用于 Windows.

Is this still an issue with a 64 bit address space? Perf is not a concern for me, so I would prefer to simplify my code and not deal with things like buffer pools anymore. Does anyone have any experience or stories about this issue? I'm using Linux, but I imagine many of the same issues apply to Windows.

推荐答案

这仍然是 64 位地址空间的问题吗?

Is this still an issue with a 64 bit address space?

不,这不是问题.

您说得对,这是 32 位系统上的问题,但它不再是 64 位系统上的问题.

You are correct that it was an issue on 32-bit systems, but it no longer is an issue on 64-bit systems.

虚拟地址空间在 64 位系统上如此之大(目前在 x86_64 处理器上为 2^48 字节,随着新的 x86_64 处理器的出现逐渐增加到 2^64),以至于耗尽了连续的由于碎片造成的虚拟地址空间实际上是不可能的(除了一些精心设计的极端情况).

The virtual address space is so large on 64-bit systems (2^48 bytes at the moment on todays x86_64 processors, and set to increase gradually to 2^64 as new x86_64 processors come out), that running out of contiguous virtual address space due to fragmentation is practically impossible (for all but some highly contrived corner cases).

(这是一个常见的直觉错误,因为 64 只是"双 32,导致人们认为 64 位地址空间在某种程度上大约是 32 位地址空间的两倍.实际上是一个完整的64 位地址空间是 32 位地址空间的 40 亿倍.)

(It is a common error of intuition caused by the fact that 64 is "only" double 32, that causes people to think that a 64-bit address space is somehow roughly double a 32-bit one. In fact a full 64-bit address space is 4 billion times as big as a 32-bit address space.)

换一种方式,如果您的 32 位守护进程一周分片到无法分配 x 字节块的阶段,那么至少需要一千个将今天的 x86_64 处理器分割成 48 位地址空间需要数年,而将未来计划的完整 64 位地址空间分割成碎片则需要8000 万年.

Put another way if it took your 32-bit daemon one week to fragment to a stage where it couldn't allocate an x byte block, than it would take at minimum one thousand years to fragment today's x86_64 processors 48-bit address spaces, and it would take 80 million years to fragment the future planned full 64-bit address space.

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

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