Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7974395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:21:24+00:00 2026-06-04T08:21:24+00:00

I have a managed_shared_memory objects that holds the map container SharedMap defined as follows.

  • 0

I have a managed_shared_memory objects that holds the map container SharedMap defined as follows.

typedef std::pair<std::string, T> ValueType;
typedef allocator<ValueType, managed_shared_memory::segment_manager> ShmemAllocator;
typedef map<std::string, T, std::less<std::string>, ShmemAllocator> SharedMap;

My issue is I need to determine the size of shared memory that I am using. The key of the map is a std::string of unknown size, and the data is a template type of unknown size where each data will varying in size.

Can anyone suggest how I can keep track of the memory I am using?

I’m new to boost::interprocess so any suggestion will help greatly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:21:26+00:00Added an answer on June 4, 2026 at 8:21 am

    I solved the issue by using exception handling. I insert into the map until a bad_alloc exception is thrown. I catch the exception and re-size the shared memory.


    I used the method static bool grow(const char *shmname, size_type extra_bytes) which should be a member function of managed_shared_memory

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have managed objects that have image properties. Since storing large blobs in CoreData
I have the following code that saves a map into shared memory using boost
I have a simple struct : struct MyType { std::string name; std::string description; }
Say I have an application in Linux that uses shared libraries ( .so files).
I have somewhat of a problem. We have a centralized interface engine that will
Hello stack overflowers, I have a desing that uses the flyweight pattern to share
I'm trying to have 2 processes communicate via an stl container - so I've
We have some scripts that we run as part of our unit tests. This
Im confused regarding which scope should i use. Here i have a module, that
I have some legacy code that uses shmget/shmat/shmdt to create, attach and manage shared

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.