Fragmentation (computing)

Fragmentation (computing)

In computer storage, fragmentation is a phenomenon in which storage space is used inefficiently, reducing storage capacity and in most cases reducing the performance. The term is also used to denote the wasted space itself.

There are three different but related forms of fragmentation: external fragmentation, internal fragmentation, and data fragmentation. Various storage allocation schemes exhibit one or more of these weaknesses. Fragmentation can be accepted in return for increase in speed or simplicity.

Contents

Memory Fragmentation

Basic Principle

"Fragmented memory" denotes all of the system's unusable free memory. Memory fragmentation usually occurs when memory is allocated dynamically (using calls like malloc).Generally, memory allocation performed during runtime is not in the form of stacks. The memory allocator wastes memory in the following ways: 1.Overhead 2.Internal Fragmentation 3.External Fragmentation. When blocks of memory are alloted during runtime, it is highly unlikely that these released blocks of memory will again form continuos large memory blocks. Hence, the free memory gets interspersed with the blocks of memory in use. The average size of blocks of memory consequently becomes quite small. This problem coupled with incomplete usage of the allocated memory results in memory fragmentation.

For example, consider a system having 5MB total memory. Let the total free memory be 2MB which the programs could use at runtime. However, due to intersperced free and used memory blocks the user is not able to allocate even 1MB of free space for a new program as all the free memory blocks are not larger than 500KB. Also, if in the 3MB allocated memory only 2MB is used then the remaining 1MB memory goes unused. This wastage of space is the major problem of internal and external memory fragmentation.

Types Of Memory Fragmentation

Memory fragmentation in a system

Overhead

The memory allocator needs to store all the information related to all memory allocations. This information includes the location, size and ownership of any free blocks, as well as other internal status details. Overhead comprises of all the additional system resources that the programming algorithm requires. A dynamic memory allocator typically stores this overhead information in the memory it manages. This leads to wastage of memory. Hence, it is considered as a part of memory fragmentation.

Internal Fragmentation

When the memory allocated is larger than required, the rest is wasted. Some reasons for excess allocation are: 1. Allocator policy - involves architectural constraints, 2. A client asks for more memory than is required. The term "internal" refers to the fact that the unusable storage is inside the allocated region. While this may seem foolish, it is often accepted in return for increased efficiency or simplicity.


1.There are some basic memory allocation rules involved. All memory allocators must adhere to it. According to the "segregated free list" allocator policy , all memory allocations must start at an address divisible by 4, 8, or 16. The memory allocator may assign blocks of only certain predefined sizes to clients. It depends upon the processor architecture. Also , extra bytes are assigned to a program for alignment and metadata.

For example, when a client requests a block of 23 bytes, it may well get 24 or 28 bytes or even more.

For example, in many file systems, each file always starts at the beginning of a cluster, because this simplifies organization and makes it easier to grow files. Any space left over between the last byte of the file and the first byte of the next cluster is a form of internal fragmentation called file slack or slack space.[1][2] Slack space is a very important source of evidence in computer forensic investigation.

Another common example: English text is often stored with one character in each 8-bit byte even though in standard ASCII encoding the most significant bit of each byte is always zero. The unused bits are a form of internal fragmentation.

Similar problems with leaving reserved resources unused appear in many other areas. For example, IP addresses can only be reserved in blocks of certain sizes, resulting in many IPs that are reserved but not actively used. This contributes to the IPv4 address shortage.

Unlike other types of fragmentation, internal fragmentation is difficult to reclaim; usually the best way to remove it is with a design change. For example, in dynamic memory allocation, memory pools drastically cut internal fragmentation by spreading the space overhead over a larger number of objects.

External Fragmentation

External fragmentation is the inability to use free memory as the free memory is divided into small blocks of memory and these blocks are interspersed with the allocated memory. It is a weakness of certain storage allocation algorithms, occurring when an application allocates and deallocates ("frees") regions of storage of varying sizes, and the allocation algorithm responds by leaving the allocated and deallocated regions interspersed. The result is that although free storage is available, it is effectively unusable because it is divided into pieces that are too small to satisfy the demands of the application. The term "external" refers to the fact that the unusable storage is outside the allocated regions.

For example, consider a situation wherein a program allocates 3 continuous blocks of memory and then frees the middle block. The memory allocator can use this free block of memory for future allocations. However, it cannot use this block if the memory to be allocated is larger in size than this free block.

External fragmentation also occurs in file systems as many files of different sizes are created, change size, and are deleted. The effect is even worse if a file which is divided into many small pieces is deleted, because this leaves similarly small regions of free spaces.

External Fragmentation


As compared to external fragmentation , overhead and internal fragmentation account for little loss in terms of wasted memory and reduced performance. External fragmentation does the most damage to the system. It is defined as:

 {External Memory Fragmentation = 1 - } \frac{Largest Block Of Free Memory}{Total Free Memory}

External fragmentation is the factor between 0 to 1. A 100% fragmentation (factor = 1) suggest that the system is completely out of usable free memory. While a 0 factor (0% fragmentation) denotes that all the free memory is in a single large block.

For example, fragmentation is 90% when 100 MB free memory is present but largest free block 
of memory for allocation is just 10 MB.

Data fragmentation

Data fragmentation occurs when a piece of data in memory is broken up into many pieces that are not close together. It is typically the result of attempting to insert a large object into storage that has already suffered external fragmentation.

For example, files in a file system are usually managed in units called blocks or clusters. When a file system is created, there is free space to store file blocks together contiguously. This allows for rapid sequential file reads and writes. However, as files are added, removed, and changed in size, the free space becomes externally fragmented, leaving only small holes in which to place new data. When a new file is written, or when an existing file is extended, the operating system puts the new data in new non-contiguous data blocks to fit into the available holes. The new data blocks are necessarily scattered, slowing access due to seek time and rotational latency of the read/write head, and incurring additional overhead to manage additional locations. This is called file system fragmentation.

When writing a new file of a known size, if there are any empty holes that are larger than that file, the operating system can avoid data fragmentation by putting the file into any one of those holes. There are a variety of algorithms for selecting which of those potential holes to put the file; each of them is a heuristic approximate solution to the bin packing problem. The "best fit" algorithm chooses the smallest hole that is big enough. The "worst fit" algorithm chooses the largest hole. The "first-fit algorithm" chooses the first hole that is big enough. The "next fit" algorithm keeps track of where each file was written.

As another example, if the nodes of a linked list are allocated consecutively in memory, this improves locality of reference and enhances data cache performance during traversal of the list. If the memory pool's free space is fragmented, new nodes will be spread throughout memory, increasing the number of cache misses.

Just as compaction can eliminate external fragmentation, data fragmentation can be eliminated by rearranging data storage so that related pieces are close together. For example, the primary job of a defragmentation tool is to rearrange blocks on disk so that the blocks of each file are contiguous. Most defragmenting utilities also attempt to reduce or eliminate free space fragmentation. Some moving garbage collectors will also move related objects close together (this is called compacting) to improve cache performance.

Performance Degradation Due To Fragmentation

Memory fragmentation is one of the most severe problems faced by system managers. Over time, it leads to degradation of system performance. Eventually memory fragmentation leads to complete loss of free memory.


Memory fragmentation is a kernel programming level problem. It becomes a critical issue when it reaches alarming levels. A real life example is of 99% fragmentation which frequently occurs during Real-time computing of applications. This fragmentation occurs just seconds before the System crashes. It is difficult to avert this System crash as it is impossible to anticipate the critical rise in levels of memory fragmentation.


According to a research conducted by International Data Corporation, the performance degradation is largely due to external fragmentation . The life-time of server is shortened by 33% by external fragmentation alone . This leads to a direct increase of 33% in the yearly budget for hardware upgrades. Thus it can be concluded that memory fragmentation has an undesirable effect not only on memory usage and processing speed of the System but also on hardware components and cost of project.

References

  1. ^ FAT Partition Efficiency: Slack
  2. ^ http://service1.symantec.com/support/on-technology.nsf/854fa02b4f5013678825731a007d06af/ec7ee0df20ad4f7a8825734e0059c256?OpenDocument
  1. http://www.edn.com/article/478952-Handling_memory_fragmentation.php
  2. http://www.sqlservercentral.com/articles/performance+tuning/performancemonitoringbyinternalfragmentationmeasur/2014/
  3. C++ Footprint and Performance Optimization, R. Alexander; G. Bensley, Sams Publisher, First edition, Page no:128, ISBN no:9780672319044
  4. Ibid, Page no:129

External links

See also


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать курсовую

Look at other dictionaries:

  • computing — noun 1. the procedure of calculating; determining something by mathematical or logical methods • Syn: ↑calculation, ↑computation • Derivationally related forms: ↑computational (for: ↑computation), ↑compute …   Useful english dictionary

  • File system fragmentation — In computing, file system fragmentation, sometimes called file system aging, is the inability of a file system to lay out related data sequentially (contiguously), an inherent phenomenon in storage backed file systems that allow in place… …   Wikipedia

  • List of computing topics — Originally, the word computing was synonymous with counting and calculating, and the science and technology of mathematical calculations. Today, computing means using computers and other computing machines. It includes their operation and usage,… …   Wikipedia

  • Hang (computing) — This article is about the computer malfunction called hanging. For the capital punishment, see hanging In computing, a hang or freeze occurs when either a single computer program or the whole system becomes unresponsive to keyboard and mouse… …   Wikipedia

  • Page (computing) — In a context of computer virtual memory, a page, memory page, or virtual page is a fixed length block of main memory, that is contiguous in both physical memory addressing and virtual memory addressing. A page is usually a smallest unit of data… …   Wikipedia

  • DF — Distrito Federal (International » Spanish) Distrito Federal (Regional) ** Data File (Computing » Telecom) * Delta Force (Governmental » Military) * Direction Finding (Governmental » Military) * Duty Free (Governmental » US Government) * Discount… …   Abbreviations dictionary

  • 6LoWPAN — est l acronyme de IPv6 Low power Wireless Personal Area Networks[note 1] ou IPv6 LoW Power wireless Area Networks[note 2]. C est également le nom d un groupe de travail de l IETF. Le groupe 6LoWPAN a défini les mécanismes d encapsulation et de… …   Wikipédia en Français

  • Paging — This article is about computer virtual memory. For the wireless communication devices, see Pager . Bank switching is also called paging. Page flipping is also called paging. For calling people in a public place see Public address. In computer… …   Wikipedia

  • File Allocation Table — For other uses, see Fat (disambiguation). FAT Developer Microsoft Full Name File Allocation Table FAT12 (12‑bit version) FAT16/FAT16B (16‑bit versions) FAT32 (32‑bit version with 28 bits used) Introduced …   Wikipedia

  • Distributed database — A distributed database is a database in which storage devices are not all attached to a common CPU. It may be stored in multiple computers located in the same physical location, or may be dispersed over a network of interconnected computers.… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”