K
karthikbalaguru
Hi,
In the case of heap , to keep track of a single chunk of memory it
requires 8 bytes of information.
That is, it requires 4 bytes to hold the size, and 4 bytes to hold the
pointer to the next block of memory. So, For every additional chunk,
even if it is only one byte long, these 8 bytes are required again, in
addition to the 1 byte actually needed to store the chunk itself.
So, there should be wastage of memory for managing the linked list
(heap).
But, How does malloc/calloc then allocate the exact size of data as
there must be some wastage of memory that has to be taken into account
while allocating in heap memory (Memory consumed for managing the
information in terms of linked list) ?
That is, Malloc should consume more space to allocate the desired
amount of data . where do the extra bytes go ?
Thx in advans,
Karthik Balaguru
In the case of heap , to keep track of a single chunk of memory it
requires 8 bytes of information.
That is, it requires 4 bytes to hold the size, and 4 bytes to hold the
pointer to the next block of memory. So, For every additional chunk,
even if it is only one byte long, these 8 bytes are required again, in
addition to the 1 byte actually needed to store the chunk itself.
So, there should be wastage of memory for managing the linked list
(heap).
But, How does malloc/calloc then allocate the exact size of data as
there must be some wastage of memory that has to be taken into account
while allocating in heap memory (Memory consumed for managing the
information in terms of linked list) ?
That is, Malloc should consume more space to allocate the desired
amount of data . where do the extra bytes go ?
Thx in advans,
Karthik Balaguru