Opened 14 years ago

Closed 12 years ago

#2645 closed Bugs (wontfix)

multimap size() returns bad count

Reported by: Daniel Christian <dan972@…> Owned by: Ion Gaztañaga
Milestone: Boost 1.38.0 Component: interprocess
Version: Boost 1.37.0 Severity: Problem
Keywords: Cc:

Description

After exhausting all available shared memory by inserting objects into a multimap until a bad_alloc exception is thrown, then deleting all the objects that were successfully inserted, calling size() will still return 1 even though the container is really empty. Also, memory is leaked if the exception is thrown during the insert as subsequent rounds of insert/delete cycles are able to insert less items than the iteration than came before it.

Some info about my test scenario... The object that I'm inserting contains an interprocess vector and dynamically allocates an interprocess_mutex using the vector's shared memory allocator storing it's pointer in the object itself. Also, the size of the vector is dynamic, but is bounded to a maximum size so that the maximum size of an object can be predicted.

I was able to work around this by performing a successful alloc/dealloc of a size equal to or larger than the size of the inserted object before doing the insert. If the alloc fails then I do not perform the insert. If I do this then the size() remains consistent and no memory is leaked.

Change History (1)

comment:1 by Ion Gaztañaga, 12 years ago

Resolution: wontfix
Status: newclosed

I couldn't reproduce the problem. Reopen the issue please, if you can find a testcase that fails.

Note: See TracTickets for help on using tickets.