Wednesday, 30 January 2013

How Malloc is Implemented ?

Malloc is require to do 2 Things

1.   Request more Virtual Address space from The Kernel if needed.--  

      It is operating system dependent,but on Linux and probably most Unixes
      the system call is  "sys_brk" which adjusts the size of a process's data segment.
      Most mallocs will do this in the same way. 

2.  To find enough Contiguous space in the Virtual Address Segment to return to
     the calling thread.

     It is Completely implementation dependent,Linux malloc, tcmalloc and jemalloc
     (amongst others) will have potentially entirely different approaches.
     These will trade off speed of allocation against the amount of fragmentation
     (and therefore unusable address space).

 eBay Ad:
  Let's Take A Look at  Online Mega Store;  ebay


Post a Comment