Contributors

Thursday, August 25, 2011

Discussion board: Malloc() and Calloc()!

http://www.coolinterview.com/interview/11749/

Everyone,

Allocation happens rightaway when a malloc or calloc is called. Only difference is that, malloc() leaves the area with garbage while calloc() initializes it with zeros.

What you guys think?

2 comments:

  1. I differ on this LK, coz when malloc/calloc is allocated based on the free memory availability a pointer is returned but only one access of usage of memory I think the whole memory would be allocated.

    ReplyDelete
  2. If address is returned by a malloc()/calloc() call, then that means the requested memory is reserved to that process. This can not be revoked till free() is called. I am still confused. Coz, my process monitor shows an increase in VM size of the process when I allocate using malloc().

    ReplyDelete