一区二区三区日韩精品-日韩经典一区二区三区-五月激情综合丁香婷婷-欧美精品中文字幕专区

分享

內(nèi)存碎片(Memory Fragmentation)

 心不留意外塵 2016-05-07

http://blog.csdn.net/adaptiver/article/details/40429061

2014

 

摘錄:

A memory allocator needs to adhere to some basic memory allocation rules. For example, all memory allocations

must start at an address that is divisible by 4, 8, or 16, depending on the processor architecture.

There may also be other reasons for the memory allocator to only assign blocks of certain predefined sizes

to its clients (cache-line size perhaps). When a client requests a block of 43 bytes, it may well get 44 or

48, or an even larger number. This extra space that results from rounding the requested size upwards is

called internal fragmentation.
External fragmentation is created when the memory allocator allocates blocks with unused gaps in between

them. This can occur, for example, when an application allocates three blocks in succession and then frees

the one in the middle. The memory allocator might reuse the middle block for future allocations, but it is

no longer possible to allocate a block as large as all free memory.

Definition of Memory Fragmentation



http://blog.csdn.net/dean_yanqing/article/details/6663775

在看OSE的文檔時(OSE Architecture User's Guide),注意到一段關(guān)于內(nèi)存碎片的總結(jié),寫的很精辟,特摘抄如下:

   原文如下(翻譯見原文后面的鏈接,某位老兄已然翻譯成中文,但不知道原文出自何處^_^)

   Why Is Memory Fragmentation Important

In embedded systems development, memory fragmentation knowledge is crucial

Ultimately, memory fragmentation leads to out-of-memory conditions, even when there might be plenty of free memory left in the system.

最終,內(nèi)存碎片會導致沒有內(nèi)存可申請,盡管總的剩余內(nèi)存看起來可以很充足(但感覺這個說法不嚴謹,物理內(nèi)存不夠時,系統(tǒng)會用虛擬內(nèi)存,硬盤頂替,所以系統(tǒng)應(yīng)該可以持續(xù)運行很長時間,但最終可能內(nèi)存耗盡)

  What Is Memory Fragmentation

Fragmented memory is the term used to describe all of a system's unusable free memory. These resources

remain unused, because the memory allocator that you are using is — for one reason or another — unable

to make this memory available to you.內(nèi)存碎片是指系統(tǒng)中不可使用的空閑內(nèi)存。因為內(nèi)存分配器不能把這些內(nèi)存分配使用

  Compile Time vs. Run Time

Memory is allocated in many different contexts. The programmer can (by way of the compiler and linker)

allocate memory for data in structures, unions, arrays, and scalars as local, static, or global variables. The

programmer can also allocate memory dynamically in run time using calls such as malloc(). When the

compiler and linker perform the memory allocation function, memory fragmentation does not arise, because

the compiler understands the lifetime of the data. The data lifetime offers the nice advantage of being

stackable (last in, first out). This makes it possible for the memory allocator to work in a very efficient and

non-fragmenting manner. Generally, memory allocations issued during run time are not stackable. Memory

allocations are independent in time, which makes the problem extremely difficult to resolve.

Internal/ External Fragmentation and Overhead

Memory allocators waste memory in three basic ways:

· Overhead

· Internal fragmentation

· External fragmentation

The memory allocator needs to store some data describing the state of its allocations. That space is generally

called overhead. This is information about the location, size, and ownership of any free blocks and about

other internal states. A run-time allocator typically has no better place to store this overhead information

than in the memory it manages.

A memory allocator needs to adhere to some basic memory allocation rules. For example, all memory allocations

must start at an address that is divisible by 4, 8, or 16, depending on the processor architecture.

There may also be other reasons for the memory allocator to only assign blocks of certain predefined sizes

to its clients (cache-line size perhaps). When a client requests a block of 43 bytes, it may well get 44 or

48, or an even larger number. This extra space that results from rounding the requested size upwards is

called internal fragmentation.

External fragmentation is created when the memory allocator allocates blocks with unused gaps in between

them. This can occur, for example, when an application allocates three blocks in succession and then frees

the one in the middle. The memory allocator might reuse the middle block for future allocations, but it is

no longer possible to allocate a block as large as all free memory.

External fragmentation is created when the memory allocator allocates blocks with unused gaps in between
them. This can occur, for example, when an application allocates three blocks in succession and then frees
the one in the middle. The memory allocator might reuse the middle block for future allocations, but it is
no longer possible to allocate a block as large as all free memory.
Provided the memory allocator doesn't change its implementation or rounding policy in run time, the
overhead and internal fragmentation remains constant throughout an application's lifetime. While overhead
and internal fragmentation may be undesired (because they waste memory), external fragmentation is the
real enemy of embedded systems. External fragmentation is the allocation problem that kills systems.
Whenever the word fragmentation is used throughout the rest of this discussion, think external fragmentation

Definition

Now we are ready for a definition of (external) memory fragmentation. Other definitions are possible, but

this is the one most commonly used. It applies to external fragmentation, but can be modified to include

internal fragmentation (by including internal fragmentation in the denominator).

Figure 5.1 Definition of Memory Fragmentation


Fragmentation is a fraction between 0 and 1. A system in which fragmentation = 1 (100%) is completely

out of memory. With all free memory in a single block (the largest), fragmentation is 0%. With one quarter

of all free memory in the largest block, fragmentation is 75%. For example, fragmentation is 99% in a

system with 5 MB of free memory, when the largest block available for allocation is 50 KB.


有朋友已經(jīng)翻譯出來,喜歡中文的請見:

http://blog./2010/04/25/%E8%BD%AC%EF%BC%9A%E5%86%85%E5%AD%98%E7%A2%8E%E7%89%87%E4%BA%A7%E7%94%9F%E5%8E%9F%E5%9B%A0%E5%8F%8A%E5%A4%84%E7%90%86%E6%8A%80%E6%9C%AF.html


0

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多

    熟妇久久人妻中文字幕| 少妇人妻精品一区二区三区| 亚洲欧美日韩国产自拍| 日韩一级毛一欧美一级乱| 高清在线精品一区二区| 老司机精品在线你懂的| 亚洲欧美日韩熟女第一页| 亚洲精品成人综合色在线| 日韩三级黄色大片免费观看| 欧美日韩国产二三四区| 精品少妇人妻av一区二区蜜桃| 欧美午夜一区二区福利视频| 中文久久乱码一区二区| 我想看亚洲一级黄色录像| 久久热在线免费视频精品| 91亚洲国产成人久久| 午夜国产成人福利视频| 五月婷日韩中文字幕四虎| 久久国内午夜福利直播| 日本深夜福利在线播放| 成人精品视频一区二区在线观看 | 久久大香蕉一区二区三区| 亚洲国产成人av毛片国产| 九九久久精品久久久精品| 亚洲一区二区精品国产av| 国产黄色高清内射熟女视频| 真实偷拍一区二区免费视频| 国产乱久久亚洲国产精品| 日韩中文字幕视频在线高清版| 91久久国产福利自产拍| 免费一区二区三区少妇| 日本在线视频播放91| 成人亚洲国产精品一区不卡| 国产综合香蕉五月婷在线| 亚洲国产av国产av| 午夜精品黄片在线播放| 精品人妻一区二区三区免费看| 成人午夜在线视频观看| 一区二区三区精品人妻| 蜜桃传媒在线正在播放| 又黄又色又爽又免费的视频|

    AI助手

    阅读时有疑惑?点击向AI助手提问吧

    联系客服

    微信扫码,添加客服企业微信

    客服QQ:

    1732698931

    联系电话:4000-999-276

    客服工作时间9:00-18:00,晚上非工作时间,请在微信或QQ留言,第二天客服上班后会立即联系您。