How is dynamically allocated memory kept track in C -


this question has answer here:

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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -