This question has to do something with the hardware level.
There is no advantage if the file is processed sequentially. If the file is processed by mapping, there is an extra wastage of memory by allocating memory to some other functions(variables etc) compared to sequentially processing.
The role of the memory management is done by a principle called,
Principle of Locality
Programs tend to reuse data and instructions that are close to each other or they have used recently
Temporal Locality
- Recently referenced items are probably be referenced in the near future
- A block tend to be accessed repeatedly
Spatial locality
- Items with nearby addresses tend to be referenced close together in time
- Near by blocks tend to be accessed
let me give you an example,
sum = 0;
int array[] = new int[10];
for (int i = 0; i < array.length; i++){
sum += array[i];
}
Data
- Access array elements in sequential – Spatial locality
- Reference sum each iteration – Temporal locality
Instructions
- Reference instructions sequentially – Spatial locality
- Cycle through loop repeatedly – Temporal locality
Back to question, since the data in the file are written in an ordered manner in the memory(like an array) there is no advantage of mapping because this is carried in the spatial locality way as I described earlier.