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 7444651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:33:36+00:00 2026-05-29T11:33:36+00:00

I know this is strange but I’m just having fun. I am attempting to

  • 0

I know this is strange but I’m just having fun.

I am attempting to transmit a std::map (instantiated using placement new in a fixed region of memory) between two processes via a socket between two machines: Master and Slave. The map I’m using has this typedef:

   // A vector of Page objects
   typedef
      std::vector<Page*,
           PageTableAllocator<Page*> >
      PageVectorType;

   // A mapping of binary 'ip address' to a PageVector
   typedef
      std::map<uint32_t,
           PageVectorType*,
           std::less<uint32_t>,
           PageTableAllocator<std::pair<uint32_t, PageVectorType*> > >
      PageTableType;

The PageTableAllocator<T> class is responsible for allocating whatever memory the STL containers may want/need into a fixed location in memory. E.g., all Page objects and STL internal structures are being instantiated in this fixed memory region. This ensures that both the std::map object and the allocator are both placed in a fixed region of memory. I’ve used GDB to make sure the map and allocator behave correctly (all memory used is in the fixed region, nothing ever goes on the application’s normal heap).

Assuming Master starts up, initializes all of it’s STL structures and the special memory region, the following happens. Slave starts, prints out its version of the page table, then looks for a Master. Slave finds a master, deletes its version of the page table, copies Master‘s version of the page table (and the special memory region), and successfully prints it out the Master‘s version of the page table. From what prodding I’ve done in GDB I can perform many read-only operations.

When trying to add to the newly copied PageTableType object, Slave faults in the allocator’s void construct (pointer p, const T& value) method. The value passed in as p points to an already allocated area of memory (as per Master‘s version of the std::map).

I don’t know anything about C++ object structure, but I’m guessing that object state from Slave‘s version of the PageTableType must be hanging around even after I replace all of the memory that the PageTableType and its allocator used. My question is if this is a valid concern. Does C++ maintain some sort of object state outside of the area of memory that object was instantiate din?

All of the objects used in the map are non-POD. Same is true for the allocator.

  • 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-05-29T11:33:36+00:00Added an answer on May 29, 2026 at 11:33 am

    To answer your specific question:

    Does C++ maintain some sort of object state outside of the area of memory that object was instantiated in?

    The answer is no. There are no other data structures set up to “track” objects or anything of the sort. C++ uses an explicit memory allocation model, so if you choose to be responsible for allocation and deallocation, then you have complete control.

    I suspect there’s something wrong in your code somewhere, but since you believe the code is correct you’re inventing some other reason why your code might be failing, and following that path instead. I would pull back, and carefully examine everything about the way your code is working right now, and see if you can determine the problem. Although the STL classes are complex (especially std::map), they’re ultimately just code and there is no hidden magic in there.

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

Sidebar

Related Questions

I know this might seem strange on the face on it but, if I
I know this is bit of a strange one but if anyone had any
I'm having this strange error for the devise_invitable extension: uninitialized constant ActiveSupport::SecureRandom But the
I know this is a basic question but for some strange reason I am
I know this sounds strange but I can't get it. Here (http://pytest.org/dev/getting-started.html) it says
Ok, I know this is a strange question, but there is a standard (fan-wise
I know this sounds strange, mixing CDI (Weld) and Spring for the controller. But
I know this is a strange situation, but consider a situation where two programmers
I don't know if it is a common problem, but this strange problem is
I know this is sort of a strange question, but as a neat freak

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.