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

  • Home
  • SEARCH
  • 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 6840483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:51:00+00:00 2026-05-26T23:51:00+00:00

How does pointer tracking work in boost serialization? I am using it to serialize

  • 0

How does pointer tracking work in boost serialization? I am using it to serialize messages between system components, and I have the impression that I get a lot of incorrectly shared objects. Is it possible that if I use shared pointers to the objects I want to serialize and a new object happens to have the same address as a previous object that has since been deleted this will incorrectly be captured as a shared refernce?

  • 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-26T23:51:00+00:00Added an answer on May 26, 2026 at 11:51 pm

    Short answer: yes, this happens.

    The reason is (as one can conclude from the other answers and comments) that this is a slight abuse of what the serialization library is meant to do. Thus, if one uses boost serialization to log objects over the course of a day (e.g. not all objects are in memory at the start of the serialization), and objects happen to have the same address, they will be incorrectly shared. This happens on shared pointers, but also on regular pointers (to my understanding).

    To fix this issue, either avoid pointers, or turn tracking off. If you turn tracking off, and still serialize shared pointers (which I currently do, although this might not be ideal), several hard coded checks in boost complain about tracking being turned off. To get around this, I hacked my local copy of the boost headers (and have to do so on every update and system used to compile) (this is pretty straight forward though, the compiler points to the right lines and they are clearly documented). If you have the choice to work without pointers, you spare yourself this trouble.

    Other than that, the logging works brilliantly though, so don’t be turned off from using boost serialization to this purpose (as some comments above suggest).

    To log objects as they arrive, just use void Log(Msg* msg) {ar & NVP(msg);} and to read them something along these lines:

    Msg* Read() {
        Msg* msg(0); 
        try {ar & NVP(msg);}
        catch (boost::archive::archive_exception const&) { }
        return msg; 
    }
    

    You would call above Read function until the pointer returned is a NULL pointer, then you know the log is finished.

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

Sidebar

Related Questions

I have some unsafe C# code that does pointer arithmetic on large blocks of
i have CSS code that does not really work on webkit browsers such as
Does anyone have any idea how to change the thickness of the text pointer
Does anyone have any good articles or explanations (blogs, examples) for pointer arithmetic? Figure
I have a pointer to a struct. I call a routine that determines whether
I have a CGFloat pointer in my header that is used to point at
With ARC, every pointer assignment does a retain by default. In that light, in
I have a question similar to How to manage object life time using Boost
why does the pointer array equivalence not work in the following case? void foo(int**
I have a small test app on Android that is meant to test tracking

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.