On Thu, Dec 16, 2010 at 11:31:16AM +0000, Joel Reymont wrote: > I'm constantly appending to a file of stock quotes (ints, longs, > doubles, etc.). I have this file mapped into memory with mmap. > > What's the most efficient way to make newly appended data available > as part of the memory mapping?
Unfortunately it's hard to reliably extend an mmap'd area. The reason is not that you can't do it, but that you might overrun another memory mapping after it, where that other mapping could be something important like your program or a shared library. The other mapping might not even be present at the time you initially map your file, but might appear as the result of an innocuous operation such as printing a string or allocating memory. Now you can, with a bunch of work, avoid this: parse /proc/self/maps, select a suitable base address for your mapping, move the mapping if it gets too large for the selected area or if another library is mapped in above it, etc. but this quickly gets very difficult. I would suggest a simpler way to solve your problem is simply to open the data file and append to it. If you need to reference the values, keep them in memory structures. Rich. -- Richard Jones Red Hat _______________________________________________ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
