Re: appending to a memory-mapped file
Re: appending to a memory-mapped file
- Subject: Re: appending to a memory-mapped file
- From: Jens Alfke <email@hidden>
- Date: Wed, 6 Jan 2010 08:36:11 -0800
On Jan 6, 2010, at 6:11 AM, Joel Reymont wrote:
> Forgive me if I'm missing something obvious but how do you append to a memory-mapped file?
> The file will obviously grow when you append to it but what's the best way to 'extend' the memory representation?
I've looked into this too. A memory-map applies not to the entire file, but to a range of bytes; and there's no way to modify one in place. You have to create a new mapping using mmap on the byte-range you added to the file. In general this means the maps will be discontiguous in address space. If that's not acceptable, you can try to reserve more address space than you need, use the beginning of it for the file map, and then position your extended maps after the first one (until you run out of space...)
I'm not an expert, just quoting from memory. I haven't tried to do the contiguous-allocation stuff myself. Look in the list archives, either in this list or darwin-userlevel, circa Oct/Nov, for my questions and the answers I got.
—Jens _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden