Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Memory can be allocated in a number of ways...the two broad ways being static and dynamically allocated. </p> <p>Static allocation means that all the memory that can be used by a program is allocated at once, and it is able to use up to that amount. </p> <p>Dynamic allocation means that when the program needs to allocate memory, it goes to the heap and puts a pointer at the first available chunk of memory (specified in size according to the dynamic allocation algorith in use). Then, as it needs (such as in an array) it takes more, <em>maintaining the pointer at that original spot so it knows where the beginning of the array is</em>. Modern computers usually do a good job of allocating resources including memory to applications, which reduces the chance of <a href="http://en.wikipedia.org/wiki/Deadlock" rel="nofollow noreferrer">deadlock</a>. On a higher level, garbage collection takes care of this memory when the object/array/whatever can be removed from memory.</p> <p>The problem here is that when free memory is given and freed at will, different programs can grab different chunks which aren't necessarily in order. This is what we call fragmentation (which is why you defrag your disk drive every now and then). When memory is allocated in a contiguous fashion, it can be read more efficiently. </p> <p>There's a huge amount of information on memory, so here is a minute amount of data for you to allocate in your own memory ;) </p> <p><a href="http://wiki.osdev.org/Memory_Allocation" rel="nofollow noreferrer">Wiki Link to OSDev on Dynamic Allocation</a><br> <a href="http://www.cplusplus.com/doc/tutorial/dynamic/" rel="nofollow noreferrer">Dynamic allocation in C++</a><br> <a href="http://www.cs.cf.ac.uk/Dave/C/node11.html" rel="nofollow noreferrer">Memory in C (This is kind of low level yet easy to understand)</a> </p> <p>Happy reading!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload