When does malloc() return null ? I want to allocate a big virtual memory which can not possibly fit on RAM, so most of it will be stored on disk. I am going to access the data sequentially so at any one time the data I am working on will fit in RAM. So I am hoping the OS will help in moving the required pages in and out of disk. I can achieve this behavior manually by allocating the required blocks on RAM but this is rather tedious. Say I have an array a. At any one time I am working only on a[i-1], a[i], a[i+1] which can fit in RAM but not the whole array. So how do I allocate the array so that I can work on it using for loops for(i=0;i<100;i++) without handling the page movements myself?