Subject: Re: [boost] [Interprocess] Managed mapped file questions
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2012-12-12 19:07:16
El 10/12/2012 21:15, Jorge Lodos Vigil escribió:
> Hi First of all, thank you for boost interprocess :-)
> I have a couple of questions:
> 1. When you grow a managed mapped file, the current
> implementation fills all the new space with zeroes. This is less
> efficient than just resizing the file. The comments in the code
> implies there is a reason, so what is it?
Interprocess tries to simulate as much as possible POSIX guarantees.
truncate() POSIX system call guarantees that "If the file is extended,
the extended area appears as if it were zero-filled". In windows,
SetFileValidData/SetEndOfFile does not zero-fill the extended size so
Interprocess needs to write it.
> 2. When the size to map is too small, take 1 or 2 bytes for
> instance, the library fails in a non elegant way. This is a corner
> case, but I could not find this documented. Is this a bug?
You need a minimum size to construct managed memory's internal
structures. Maybe the behaviour should be documented. What do you mean
with "non-elegant", your application crashses? Nevertheless, mapping 1
or 2 bytes you waste resources, as the OS will map at least one page (4K
on most 32 bit systems and 64 K on Windows).