Boost logo

Boost Users :

Subject: [Boost-users] [interprocess] Memory deallocation doesn't seem to work
From: Stephan Menzel (stephan.menzel_at_[hidden])
Date: 2009-09-23 09:43:29


Hi there,

I seem to get a strange behavior with 1.40 on windows concerning deallocation.

Basically, I have a managed shared memory segment and I allocate
several blocks of mem in it

typedef boost::interprocess::managed_windows_shared_memory shared_segment;
typedef boost::shared_ptr<shared_segment> shared_segment_ptr;

...
shared_segment_ptr p = new shared_segment(create_only,
buffername.c_str(), begin_size);
...

Now I have several allocate_aligned operations:

ptr = m_segment->allocate_aligned(static_cast<size_t>(rawsize), 128);

Now after a while the segment will have no more room for further
blocks. So I delete some of them to gain more room:

m_segment->deallocate(raw.get());

(raw is an interprocess::offset_ptr)

I debugged into this and there's indeed deallocation functionality
called but when I try to allocate afterwards...

ptr = m_segment->allocate_aligned(static_cast<size_t>(rawsize), 128);

... I get an interprocess::bad_alloc

This makes me believe that either deallocate didn't do a good job or
I have to do something after the deallocate() to really make it happen.
I looked into the docs for this but there was nothing mentioned so I
suppose deallocate() should suffice.
I think fragmentation is not really a problem here. We're talking about
a few >1MB blocks in a 30MB segment. Plus some administrative overhead.
Any ideas what's going on here?

Cheers,
Stephan


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net