Opened 16 years ago

Closed 16 years ago

#676 closed Bugs (Wont Fix)

Shmem serious bugs

Reported by: nobody Owned by: Ion Gaztañaga
Milestone: Component: None
Version: None Severity:
Keywords: Cc:

Description

Hi,

these are the 2 things I have found so far using the 
shmem lib.

My understading is that this is not yet a boost 
library but it has been accepted to become one in the 
near future. Accept my apologies if I shouldn´t had 
posted here.

 1) If you try to use a node allocator with a 
fixed_named_shared_object it won't compile. Works fine 
for non fixed segments.

 2) If you concatenate with the '+=' operator a 
boost::string with a NULL terminated str (char *) in a 
loop up to N times, you get bad_alloc sooner than if 
you do a single allocation of the same lenght of the N 
previous allocations. So concatenating is wasting 
memory somehow, as you can allocate longer strings 
with a single allocation than with N equivalent 
concatenations.

Thanks.

(bblasi at jblasi dot com)

Change History (2)

comment:1 by nobody, 16 years ago

Logged In: NO 

The second is not a bug, it's normal. If you allocate memory step by step, you will end fragmenting the memory and the memory manager is not going to find a big enough memory chunk to request your need. For example, if you have an string placed in the first bytes of a segment:

[XXXXXXXXXXXXXXXXXXXXXXXXXXXXX.........................]

If you do incremental assignment, since Shmem has no memory expansion features (it can expand your current buffer, only can allocate a bigger one), you won't be able to allocate an string bigger than the half of the segment. On the other hand you can take an empty string, and assign an string with the full size of the segment because there is only one allocation involved. The same happens with common standard string implementations, the difference is that shared memory is much more limited in space than the heap.

Memory expansion features for vectors and string were implemented in Boost.Interprocess.

I will try to investigate what's happening with fixed_named_shared_object and node_allocator.

comment:2 by Ion Gaztañaga, 16 years ago

Status: assignedclosed
Logged In: YES 
user_id=1416985
Originator: NO

I have no time to spend on Shmem, so I'll close this bug. Please use Interprocess (which is the official Boost library, Shmem is not really a boost library).
Note: See TracTickets for help on using tickets.