Boost logo

Boost Users :

Subject: Re: [Boost-users] How can I free memory allocated when deserializing with boost::archive::text_iarchive
From: Tim Moore (tim_at_[hidden])
Date: 2013-02-04 15:24:08


On 2013-02-04 14:46, Adlai Shawareb wrote:
> Hi,
>
> Does anyone know how we can free memory that is dynamically allocated
> by boost::archive::text_iarchive when deserializing an archive?
>
> We have tried using 'delete' and free() on the pointer when we finish
> with it, but it results in a crash.
>
> How does Boost dynamically allocate memory, 'new', 'malloc', or
> other?
>
> We tried a shared_ptr, but were getting compile errors related to the
> include files, and have not gone back to track that down. So if there
> is a simple way to free the memory that would be best for our
> application.
>
> Thanks,
>
> Adlai Shawareb
>
> Vytronus, Inc.

The memory allocation is described here:

http://www.boost.org/doc/libs/1_52_0/libs/serialization/doc/serialization.html#constructors

I have no problem calling delete on any pointer to a object constructed
when deserializing an archive.

Nor have I had any problem deserializing to a shared_ptr or other smart
pointer types.

Perhaps you could provide a small self-contained example demonstrating
your problem ??

Tim


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