How does free() know how many bytes to free?

Answer Posted / vadivel t

Heap memory menager is a person, who is responsible for
dynamic memory allocation. He will maintains a internal
data structure(table) to update the information on free and
allocated memory pools. when memory is allocated using
malloc or calloc, the heap memory manager will update the
table(which tells, no of bytes allocated to a particular
pointer) and returns the base address to the application.
when application calls free() with the pointer to be freed
as a argument, free will look into the table which holds no
of bytes allocated for that pointer. And it will free those
many bytes from the base address. Again the freed memory
shall be added to a free memory pool so that other fellows
who needs memory can utilise it.

Is This Answer Correct ?    6 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

a direct address that identifies a location by means of its displacement from a base address or segment a) absolute address b) relative address c) relative mode d) absolute mode

660


What is graph in c?

585


Explain what is the concatenation operator?

628


what is the basis for selection of arrays or pointers as data structure in a program

3789


a value that does not change during program execution a) variabe b) argument c) parameter d) none

698






a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above

686


write a program to reverse a every alternetive words in a string in a place. EX: Input is "this is the line of text" Output should be "shit is eht line fo text" Please any one tell me code for that.

1579


What is the collection of communication lines and routers called?

614


How can I read data from data files with particular formats?

606


What are the modifiers available in c programming language?

742


If the size of int data type is two bytes, what is the range of signed int data type?

595


Define Spanning-Tree Protocol (STP)

646


What are the properties of union in c?

591


What is the purpose of void in c?

620


What is malloc calloc and realloc in c?

671