Bloomberg LP Interview Question
Financial Software DevelopersMalloc() always allocates bytes from the heap which is present in the virtual memory. The programmer does not have any rights to access RAM directly thru his program (except in rare occasions when working at kernel level).
So, malloc() will always work irrespective of the usage of RAM. The usage of RAM affects paging & execution speed.
Well spotted! malloc requests a contiguous block in virtual memory. This block can be mapped into physical memory in many ways (even if the physical storage is fragmented which is often true).
As far I have read about malloc and calloc, malloc() allocates a single block of contiguous storage, whereas calloc() allocates multiple blocks of storage, each block of the same size.
Hence, in this case, memory cannot be allocated and malloc() should return NULL.
No.It needs continous strip of memory..
- Maankutti October 09, 2009