|
![](/i/fill.gif) |
Le 31/01/2011 14:28, Invisible a écrit :
>>> OK, now I must know... WTF is this "memmap" that I keep hearing about?
>>
>> http://lmgtfy.com/?q=what+is+memmap
>
> I'm not sure I completely understand.
>
> So, a memory-mapped file is a region of virtual memory which contains
> the same data as a file on disk? And when you access anything in that
> region, the necessary pages are read from disk? (And, presumably, saved
> back to that file rather than being copied to swap when physical memory
> is required.)
>
> So... how do you change the size of the file then?
For a memmap-ed file, usually you don't.
For a normal file, opening in append mode, and using seek to reach the
right last byte counted from the start followed by either a write, if
you want to extend it or directly a truncate call if you want it shorter.
memmap is just a "convenient" way to access the bytes in a file, just
reading and writing them as an array in memory.
seek, read & write are just as good (but file oriented, so if your huge
and smart code is expecting an array of bytes... memmap come easy for
the lazy programers)
--
Software is like dirt - it costs time and money to change it and move it
around.
Just because you can't see it, it doesn't weigh anything,
and you can't drill a hole in it and stick a rivet into it doesn't mean
it's free.
Post a reply to this message
|
![](/i/fill.gif) |