FACTOID # 30: Finns are perhaps the world's greatest athletes, ranking first in medals per capita for Summer Olympics, and third for Winter Olympics.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

SEARCH ALL

FACTS & STATISTICS    Advanced view

Search encyclopedia, statistics and forums:

 

 

(* = Graphable)

 

 


Encyclopedia > Dynamic memory allocation

In computer science, dynamic memory allocation is the allocation of memory storage for use in a computer program during the runtime of that program. It is a way of distributing ownership of limited memory resources among many pieces of data and code. A dynamically allocated object remains allocated until it is deallocated explicitly, either by the programmer or by a garbage collector; this is notably different from automatic and static memory allocation. It is said that such an object has dynamic lifetime. Computer science is the study of the theoretical foundations of information and computation and their implementation and application in computer systems. ... To meet Wikipedias quality standards, this article or section may require cleanup. ... A computer program or software program (usually abbreviated to a program) is a step-by-step list of instructions written for a particular computer architecture in a particular computer programming language. ... In computer science, run time (with a space, though often its spelled without one) describes the operation of a computer program, the duration of its execution, from beginning to termination (compare compile time). ... In computer science, garbage collection (also known as GC) is a form of automatic memory management. ... It has been suggested that this article or section be merged with Function stack. ... Unlike dynamic memory allocation where memory is allocated as required at run-time, static memory allocation refers to the process of allocating memory at compile-time; before the associated program is executed. ...


The task of fulfilling an allocation request, which involves finding a block of unused memory of a certain size in the heap, is a difficult problem. A wide variety of solutions have been proposed, including:

The main problem for most dynamic memory allocation algorithms is to avoid both internal and external fragmentation while keeping both allocation and deallocation efficient. Also, most algorithms in use have the problem that a large number of small allocations can cause wasted space due to collecting metadata; thus most programmers avoid this, sometimes by using a strategy called chunking. A free list is a data structure used in a scheme for dynamic memory allocation. ... In computer operating systems, paging memory allocation algorithms divide computer memory into small partitions, and allocates memory using a page as the smallest building block. ... The buddy memory allocation technique is a memory allocation technique that divides memory into partitions to try and satisfy a memory request as suitably as possible. ... In a computer operating system, fragmentation is a consequence of allocating and freeing differently-sized blocks of data storage. ... In a computer operating system, fragmentation is a consequence of allocating and freeing differently-sized blocks of data storage. ... Fragmentation is a term that occurs in several fields and describes a process of something breaking or being divided into pieces (fragments). ... Metadata is data about data. ... The term chunking is used in computer programming in multiple ways: In memory management Typical modern software systems allocate memory dynamically from structures known as heaps. ...

Contents


Fixed-size-blocks allocation

One solution is to have a LIFO linked list of fixed size blocks of memory. This works astonishingly well for simple embedded systems. In a stack, the topmost item, which is added last, is taken out first. ... In computer science, a linked list is one of the fundamental data structures used in computer programming. ... An embedded system is a special-purpose computer controlled electo-mechanical system in which the computer is completely encapsulated by the device it controls. ...


Buddy blocks

Another solution is to have a binary buddy block allocator. In this system, memory is allocated from a large block of memory that is a power of two in size. If the block is more than twice as large as desired, it is broken in two. One of the halves is selected, and the process repeats (checking the size again and splitting if needed) until the block is just large enough. The buddy memory allocation technique is a memory allocation technique that divides memory into partitions to try and satisfy a memory request as suitably as possible. ... In mathematics, a power of two is any of the nonnegative integer powers of the number two; in other words, two times itself a certain number of times. ...


All the buddies of a particular size are kept in a sorted linked list or tree. When a block is freed, it is compared to its buddy. If they are both free, they are combined and placed in the next-largest size buddy-block list. (When a block is allocated, the allocator will start with the smallest sufficiently large block avoiding needlessly breaking blocks) In computer science, a tree is a widely-used computer data structure that emulates a tree structure with a set of linked nodes. ...


Note that buddy block allocators are not unique to real-time operating systems, they are also used in conventional operating systems (such as the Linux kernel). A real-time operating system (RTOS) is a class of operating system intended for real-time applications. ... Tux is the Linux mascot. ...


Heap-based memory allocation

In heap-based memory allocation, memory is allocated from a large pool of unused memory area called the heap (this has nothing to do with the heap data structure). The size of the memory allocation can be determined at run-time, and the lifetime of the allocation is not dependent on the current procedure or stack frame. The region of allocated memory is accessed indirectly, usually via a reference. The precise algorithm used to organize the memory area and allocate and deallocate chunks is hidden behind an abstract interface and may use any of the methods described above. In computer science, a heap is a specialized tree-based data structure. ... This article discusses a general notion of reference in computing. ...


In constrast, the call stack memory is usually of limited size and the lifetime of the allocation depends on the duration of the corresponding functions. In computer science, a call stack is a special stack which stores information about the active subroutines of a computer program. ...


See also

In computing, malloc is a subroutine provided in the C programming languages standard library for performing dynamic memory allocation. ... Look up Slab in Wiktionary, the free dictionary Slab can refer to: Slab (computer science) - a unit of storage unique to the NCR 315. ... In computing, mmap() is a POSIX-compliant Unix system call that maps files or devices into memory. ... hazard pointer ... The Hoard memory allocator, or Hoard, is a memory allocator for Linux, Solaris, Microsoft Windows and other operating systems. ... Memory pools allow dynamic memory allocation comparable to malloc or the Operator new in C++. As those implementations suffer from fragmentation because of variable block sizes, it can be impossible to use them in a real time system due to performance. ... An obstack is a stack of objects (data items) which is grown dynamically. ... Unlike dynamic memory allocation where memory is allocated as required at run-time, static memory allocation refers to the process of allocating memory at compile-time; before the associated program is executed. ...

References

  • Donald Knuth. Fundamental Algorithms, Third Edition. Addison-Wesley, 1997. ISBN 0-201-89683-4. Section 2.4: Dynamic Storage Allocation, pp.435–456.
  • Simple Memory Allocation Algorithms on OSDEV Community

  Results from FactBites:
 
Dynamic memory allocation Summary (1314 words)
A memory allocator's task is to respond to a memory request based on its knowledge of the amount and location of free and used memory.
In allocation, the leftmost region of the tree that fulfills the memory request is identified as being in-use.
A dynamically allocated object remains allocated until it is deallocated explicitly, either by the programmer or by a garbage collector; this is notably different from automatic and static memory allocation.
Dynamic memory allocation - Wikipedia, the free encyclopedia (522 words)
A dynamically allocated object remains allocated until it is deallocated explicitly, either by the programmer or by a garbage collector; this is notably different from automatic and static memory allocation.
In this system, memory is allocated from a large block of memory that is a power of two in size.
In constrast, the call stack memory is usually of limited size and the lifetime of the allocation depends on the duration of the corresponding functions.
  More results at FactBites »


 
 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms, 1022, m