29 Nov
2010
29 Nov
'10
4:08 p.m.
There is a fixed overhead for the header and another one for each allocation (bookeeping information for deallocation), another overhead for each named object (you need to store the name, and other information...). You can also have memory fragmentation (if you allocate/deallocate many objects), just like with heap memory and this overhead is use-dependent.
Take in care that the OS will reserve shared memory in page units (usually 4KB-64KB bytes, depending on HW/OS) so creating a segment of 800 will waste a whole page. See mapped_region::get_page_size() to know the size of a page in your platform.
On my machine, the page size is 4096 bytes. In general, is it advisable to allocate memory in multiples of the page size? Thanks, - Aditya