3 ms·
> if I read a gigabyte from a file with the read call `mmap` signals the kernel that you want to use the data someday. You `mmap` it, it automatically handles
by ElectricalUnion 4y ago
> if I read a gigabyte from a file with the read call
`mmap` signals the kernel that you want to use the data someday. You `mmap` it, it automatically handles fetching and throwing unused bytes away.
`read` signals the kernel that you want to do something with the data now.
You `read` it, you need it in the memory now.
> why the kernel can't see that it's unused allocated memory
Only a in-process garbage collector would really know what part of your memory is unused. The kernel can't really know for sure.