Boost logo

Boost Users :

Subject: Re: [Boost-users] Hitting a mysterious memory limit for shared mutex
From: Stefan Stefansson (stefan_at_[hidden])
Date: 2010-04-07 07:30:51


Hello again.

Since I haven't gotten any replies to my question I went ahead and
created a working example in the hope that someone can take it and try
it out.

I've verified that this problem persists on at least one other system
(mine is 32 bit and the other one is 64 bit, both linux).

Here is the code:
http://pastebin.com/wpqk9x0N

Any ideas are appreciated, also any comments on whether I should be
using some other synchronization mechanism rather than
named_upgradable_mutex (since I don't need the upgradable part... just
need shared and exclusive locking).

Kind regards, Stefan Freyr.

On Tue, Apr 6, 2010 at 5:30 PM, Stefan Stefansson <stefan_at_[hidden]> wrote:
> Hi.
>
> I'm trying to expose a "framebuffer API" via a C interface in a shared library.
>
> The idea is to have something like the following scenario:
>
> 1. Call "init" to initialize a sharable mutex and a shared memory
> segment for the framebuffer.
> 2. A process that wants to read the framebuffer would obtain a shared
> lock by calling ruauv_camReadLock() and get a handle on the mutex back
> (as a void*).
> 3. After doing what it needs to the framebuffer (which usually means
> copying it) it would call ruauv_camReadUnlock(void*) and send in the
> handle it got from step 2.
>
> I've implemented this and a test application that simply loops and
> does this repeatedly but the problem I have is that after exactly
> 65501 iterations I get an error stating:
>
> terminate called after throwing an instance of
> 'boost::interprocess::interprocess_exception'
>  what():  Cannot allocate memory
>
> Here is a link to the relevant code that I'm using:
> http://pastebin.com/4ERTWEzj
>
> If it's of any relevance, I'm creating a shared library from the code
> above the main() in this snippet and then I'm compiling the main()
> into an executable and linking with the library.
>
> As I say, the for loop is able to iterate 65501 times and then fails
> the next time (the failure occurs at line 33 in the snippet above).
>
> I would really appreciate any help.
>
> --
> Kær kveðja | With best regards
> Stefán Freyr Stefánsson
>
>
> Tölvunarfræðideild | School of Computer Science
> Sérfræðingur | Specialist
> Beint/Direct +354 599 6534 | GSM/Mobile +354 822 1667
> Háskólinn í Reykjavík | Reykjavik University
> stefan_at_[hidden]
> Menntavegur 1, Nauthólsvík | 101 Reykjavík | Iceland
> Sími/Tel +354 599 6200 | Fax + 354 599 6201
> www.ru.is
>

-- 
Kær kveðja | With best regards
Stefán Freyr Stefánsson
Tölvunarfræðideild | School of Computer Science
Sérfræðingur | Specialist
Beint/Direct +354 599 6534 | GSM/Mobile +354 822 1667
Háskólinn í Reykjavík | Reykjavik University
stefan_at_[hidden]
Menntavegur 1, Nauthólsvík | 101 Reykjavík | Iceland
Sími/Tel +354 599 6200 | Fax + 354 599 6201
www.ru.is

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