How is dynamically allocated memory kept track in C -
this question has answer here:
- how free know how free? 11 answers
we allocate memory dynamically in c using malloc() , receive pointer location in heap. use free() deallocate memory, passing same pointer value argumnet.
the question how free() know how deallocate.. considering fact can resize memory block allocated malloc().
is there related hash tables here?
the original technique allocate larger block , store size @ beginning, part application didn't see. space holds size , possibly links thread free blocks reuse.
there issues tricks, however, such poor cache , memory management behavior. using memory right in block tends page things in unnecessarily , create dirty pages complicate sharing , copy-on-write.
so more advanced technique keep separate directory. exotic approaches have been developed areas of memory use same power-of-two sizes.
in general, answer is: a separate data structure allocated keep state.
Comments
Post a Comment