Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is the benefit of mmap with MMAP_PRIVATE flag versus malloc

malloc will use mmap if this is beneficial.

What is the benefit of mmap with MMAP_PRIVATE flag and file instead of just use malloc?

Access to the memory is read / write.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

From what I know, the only benefit would be that system will swap the memory into the file instead of system swapfile. This file may be on faster disk etc.

Any other reason someone may decide to use it this way?

>Solution :

It really depends on the application. But one application may be mapping a shared memory segment (file), to which you want to make local modifications, without affecting the other users of that same shared memory. Thanks to Copy-on-Write only those pages of the memory segment that were actually altered need to be copied.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading