Boost logo

Boost Users :

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


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

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