Read Apple’s File-System Performance Guidelines, specifically the Mapping Files Into Memory section.

Read the File System Programming Guide, specifically File System Advanced Programming Topics, focusing on the Mapping Files Into Memory section.

Read the man pages for mmap and munmap.