[Interprocess] Allocation algorithms
Hello, I need to allocate and fill about 10 big memories areas (several Gb) at the startup of my program. The data will never be modified or freed after during the program lifetime, and will be *only read* an other processes. What allocation algorithm should I take from the ones provided by the library ? Should I create a new one, more efficient (no reallocations, no race conditions...) ? Thanks.
You may try the *shared_memory_object* class defined in *
boost\interprocess\shared_memory_object.hpp*. The *truncate *function is to
allocate desired size of memory. Also, the *mapped_region *class defined in
*boost\interprocess\mapped_region.hpp* should be used to get the address of
shared memory and map to client program. Refer to this page for more
details:
http://www.boost.org/doc/libs/1_53_0/doc/html/interprocess/sharedmemorybetwe...
.
Best regards!
On Mon, Jun 24, 2013 at 7:33 AM, Oodini
Hello,
I need to allocate and fill about 10 big memories areas (several Gb) at the startup of my program. The data will never be modified or freed after during the program lifetime, and will be *only read* an other processes.
What allocation algorithm should I take from the ones provided by the library ? Should I create a new one, more efficient (no reallocations, no race conditions...) ?
Thanks. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
That's what I started with at the beginning, but as I'd like to use containers (vectors, maps...), it seems I have to use a managed shared memory. ----- Mail original -----
De: "Adrian Yu"
À: boost-users@lists.boost.org Envoyé: Lundi 24 Juin 2013 07:26:49 Objet: Re: [Boost-users] [Interprocess] Allocation algorithms You may try the shared_memory_object class defined in boost\interprocess\shared_memory_object.hpp . The truncate function is to allocate desired size of memory. Also, the mapped_region class defined in boost\interprocess\mapped_region.hpp should be used to get the address of shared memory and map to client program. Refer to this page for more details: http://www.boost.org/doc/libs/1_53_0/doc/html/interprocess/sharedmemorybetwe... .
Best regards!
On Mon, Jun 24, 2013 at 7:33 AM, Oodini < svdbg___@free.fr > wrote:
Hello,
I need to allocate and fill about 10 big memories areas (several Gb) at the startup of my program. The data will never be modified or freed after during the program lifetime, and will be *only read* an other processes.
What allocation algorithm should I take from the ones provided by the library ? Should I create a new one, more efficient (no reallocations, no race conditions...) ?
Thanks. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
El 24/06/2013 1:33, Oodini escribió:
Hello,
I need to allocate and fill about 10 big memories areas (several Gb) at the startup of my program. The data will never be modified or freed after during the program lifetime, and will be *only read* an other processes.
What allocation algorithm should I take from the ones provided by the library ? Should I create a new one, more efficient (no reallocations, no race conditions...) ?
Use the default one, but open the managed shared memory as open_read_only. That will map shared memory with read-only protection and will avoid using any internal mutexes (as using mutexes on the shared memory will lead to access violation). Best, Ion
participants (3)
-
Adrian Yu
-
Ion Gaztañaga
-
Oodini