5

As processes are loaded and removed from memory , the free memory space is broken into little pieces ,causing fragmentation ... but how does this happen ? And what is the best solution to external fragmentation ?

  • External fragmentation can be reduced by compaction. One way is to shuffle memory contents to place all free memory together in one large block. Also compaction is possible only if relocation is dynamic, and is done at execution time. – Sunil Bojanapally Dec 01 '12 at 11:12

4 Answers4

5

External fragmentation exists when there is enough total memory to satisfy a request (from a process usually), but the total required memory is not available at a contiguous location i.e, its fragmented.

Solution to external fragmentation :

1) Compaction : shuffling the fragmented memory into one contiguous location.

2) Virtual memory addressing by using paging and segmentation.

shamim
  • 51
  • 1
4

External Fragmentation

External fragmentation happens when a dynamic memory allocation algorithm allocates some memory and a small piece is left over that cannot be effectively used. If too much external fragmentation occurs, the amount of usable memory is drastically reduced. Total memory space exists to satisfy a request, but it is not contiguous. see following example

 0x0000 0x1000  0x2000  
   A    B     C               //Allocated three blocks A, B, and C, of size 0x1000.
   A          C         //Freed block B

Now Notice that the memory that B used cannot be included for an allocation larger than B's size

Ravindra Bagale
  • 17,226
  • 9
  • 43
  • 70
  • Do you know why it is called external? – Timothy Leung Dec 11 '13 at 21:14
  • 2
    Internal fragmentation refers to wasted bits inside of a given block of memory, in this case a page. External fragmentation on the other hand refers to wasting of memory external to the block/page. – nivla12345 Oct 04 '15 at 03:38
  • Correct me if I'm wrong, but this answer seems like it's mixing up external and internal fragmentation. A memory allocation algorithm is designed to minimize internal fragmentation (every memory that it touches is inside a block/page). The virtual addressing scheme (paged vs segmented) is responsible for external fragmentation. – countunique Mar 12 '17 at 18:09
  • nomenclature: internal fragmentation - unusable memory is inside allocated blocks of memory, external fragmentation - unusable memory is outside allocated blocks of memory – user1770426 Jul 05 '17 at 18:35
2

External fragmentation can be reduced by compaction or shuffle memory contents to place all free memory together in one large block. To make compaction feasible, relocation should be dynamic.External fragmentation is also avoided by using paging technique.

stephen
  • 21
  • 1
1

The best solution to avoid external fragmentation is Paging. Paging is a memory management technique usually used by virtual memory operating systems to help ensure that the data you need is available as quickly as possible. for more see this : What's the difference between operating system "swap" and "page"?

In case of Paging there is no external fragmentation but it doesn't avoid internal fragmentation.

Community
  • 1
  • 1
Jazib_Prince
  • 39
  • 11