Hi,
The operating system keeps a table that contains information on where memory was allocated and how much. When you deallocate memory, the operating system just deletes an entry from its allocation table. I'm not 100% sure that's how it works though.
Hope this helps.
Hi,
The operating system keeps a table that contains information on where memory was allocated and how much. When you deallocate memory, the operating system just deletes an entry from its allocation table. I'm not 100% sure that's how it works though.
Hope this helps.
The OS hasn't much to do with it; the OS simply allocates pages and assigns
them to the process; malloc and friends turn that raw memory into a 'heap'
from which malloc takes memory and free returns it again. Most (if not all)
implementations prepend a small block to the allocated block in which the size
of the block is stored. The free() function uses that information when it has to
return that block to the heap again.
The OS hasn't much to do with it; the OS simply allocates pages and assigns
them to the process; malloc and friends turn that raw memory into a 'heap'
from which malloc takes memory and free returns it again. Most (if not all)
implementations prepend a small block to the allocated block in which the size
of the block is stored. The free() function uses that information when it has to
return that block to the heap again.
Comment