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.
problem 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:
3)Buddy memory allocation
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.
How Does Dynamic Memory Allocation Work??
The key idea is to regard all the available memory as a large global pool that can be used for any purpose whatsoever. When you need memory, you ask for just the amount you need; it is given to you from the global pool and is marked as being no longer `free' so that a subsequent request for memory does not allocate this same block again for a different purpose. Memory allocation is done by some sort of procedure call; in C, malloc ( n ) allocates a block of memory of size n bytes.
It is your responsibility to return memory to the global pool when you are finished with it; when you do so it will be marked `free' again and be available for other uses (you might get it again the next time you request some memory).
To continue, we imagine that all the available memory is one large array to be used as a global pool:
We use gray shading to indicate the regions of memory that belong to the global pool, i.e. which are free. At present, all of it is free.
Now, if the user needs memory to store the name JOE, he must requests enough space to store the string "JOE" . As it happens, in C, all strings must be terminated by a special character called `NULL' whose code is 0 and which is written \0 . Therefore, the user needs 3 bytes to store J , O , and E , plus an additional byte for NULL. Thus he requests 4 bytes by calling malloc(4) .
Suppose he is given the first 4 bytes from the pool; then memory would now look like this:
The memory allocator keeps track of what memory is free and what memory has been allocated. It now knows that the 4 bytes which it gave to the user are no longer free; they are no longer in the global pool. This we represent visually by the fact that these bytes are no longer shaded gray.
The question marks now visible indicate that we do not know in what state the bits of this block of memory really are.
A memory allocator typically makes no guarantee about this issue. The block of memory which is allocated and returned to the user must be presumed to contain garbage . It is the responsibility of the user to then initialize this block properly so that its contents become meaningful.
C++ provides two dynamic allocation operators: new and delete . These operators are used to allocate and free memory at run time. Dynamic allocation is an important partof almost all real-world programs. As explained in Part One, C++ also supportsdynamic memory allocation functions, called malloc() and free(). These are includedfor the sake of compatibility with C. However, for C++ code, you should use the new and delete operators because they have several advantages.The new operator allocates memory and returns a pointer to the start of it. The delete operator frees memory previously allocated using new.
You may also like this : Self Defending Networks, Semantic Web, Computer Intelligence Application, Cooperative Linux, Longhorn, Mesh Radio, Parallel Virtual Machine, Linux Virtual Server, Location Independent Naming, PHANToM, Multiprotocol Label Switching, Next Generation Secure Computing Base, NGSCB, Reconfigurable computing, Sky X Technology, Smart Client Application Development using .NET, Spawning Networks, SPCS, Speed protocol processors, Strata flash Memory, Swarm Intelligence, The Callpaper Concept, IP spoofing, Internet Access via Cable TV Network, Face Recognition Technology, FireWire, Param 10000, The Deep Web, Virtual Campus, VoiceXML, Wireless USB, Refactoring, On-line Analytical Processing (OLAP), Pivot Vector Space Approach in Audio-Video Mixing, MPEG-7, Adding Intelligence to Internet, Silverlight,DNA chips, Remote Administration Trojan's, Thermography, AJAX , Alternative Models Of Computation, Amorphous Computing and Swarm Intelligence, Windows DNA, Laptop Computer, Intelligent Software Agents, Self-Managing Computing, Hurd, Intel Centrino Mobile Technology, Computer Seminars Reports and PPT
Labels : Software Engineering Seminar Topics, General Seminar Topics for Computer Science(CSE), Advanced Seminar Topics Computer Science(CSE), Computer Science(CSE) Seminar Topics Full Reports Presentations, Computer Science(CSE) IEEE Seminar Topics, Computer Science(CSE) Seminar Topics with Abstract, Computer Science(CSE) Seminar Topics 2011|2010|2012|2009, Computer Science(CSE) Paper Presentations 2011, Computer Science(CSE),IT and MCA Seminar Topics|Reports|PPT|PDF, MCA Seminar Topics Latest, Latest MCA Seminar Topics 2012|2011|2010|2009, MCA Seminar Topics Free Download, MCA Seminar Topics with Abstract, MCA Seminar Topics 2009|2010|2011|2012, Advanced MCA Seminar Topics