|
Boost Users : |
Subject: [Boost-users] How can I free memory allocated when deserializing with boost::archive::text_iarchive
From: Adlai Shawareb (adlai_at_[hidden])
Date: 2013-02-04 21:29:48
Thanks for your reply. Here is a code sample:
std::istringstream istr;
<* put data into istr here *>
boost::archive::text_iarchive ia(istr_);
Message* p_temp;
ia & p_temp;
mpBaseIncomingMessage = p_temp; // mpBaseIncomingMessage is of type (Message *)
mpIncomingMessage = static_cast<SystemMessage*>(mpBaseIncomingMessage); // mpIncomingMessage is a pointer to a class derived from Message
mObjectCallbackMap.process(mpIncomingMessage->mEvent); // execute a callback for this event
delete mpIncomingMessage; // delete the allocated memory
We then see a crash on either the " mObjectCallbackMap.process..." line or the " delete mpIncomingMessage", but only when certain actions are taken by the system.
Any thoughts would be greatly appreciated.
Regards,
Adlai
-----Original Message-----
From: Boost-users [mailto:boost-users-bounces_at_[hidden]] On Behalf Of boost-users-request_at_[hidden]
Sent: Monday, February 04, 2013 1:11 PM
To: boost-users_at_[hidden]
Subject: Boost-users Digest, Vol 3349, Issue 6
Send Boost-users mailing list submissions to
boost-users_at_[hidden]
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.boost.org/mailman/listinfo.cgi/boost-users
or, via email, send a message with subject or body 'help' to
boost-users-request_at_[hidden]
You can reach the person managing the list at
boost-users-owner_at_[hidden]
When replying, please edit your Subject line so it is more specific than "Re: Contents of Boost-users digest..."
Today's Topics:
1. Re: Crediting the Work of Others (Bill Buklis)
2. How can I free memory allocated when deserializing with
boost::archive::text_iarchive (Adlai Shawareb)
3. Re: in IOS, thread_info object is being destructed before the
thread finishes executing (Nat Linden)
4. Re: Undirected version of dijkstra shortest path on directed
graph. (Jeremiah Willcock)
5. Re: Crediting the Work of Others (Algocoders)
6. Re: How can I free memory allocated when deserializing with
boost::archive::text_iarchive (Tim Moore)
7. [mpl::integral_c] Compiler Error with Visual Studio 2010
(Christian Henning)
8. Re: [mpl::integral_c] Compiler Error with Visual Studio 2010
(Nathan Crookston)
----------------------------------------------------------------------
Message: 1
Date: Mon, 04 Feb 2013 13:18:47 -0600
From: Bill Buklis <boostusr_at_[hidden]>
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] Crediting the Work of Others
Message-ID: <51100997.1050909_at_[hidden]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
On 2/1/2013 1:33 PM, Algocoders wrote:
> Dave Abrahams <dave <at> boostpro.com> writes:
>
>>
>> It has come to my attention that this book appears to use the work of
>> others without attribution. I'd like to give the authors a chance to
>> explain why that appearance is false. From what you can see in
>> Amazon's limited preview of the book, one can find numerous instances
>> of code lifted from Andrew Sutton's "origin" library.
>> Some of the data structures have been renamed or had the case changed.
>> Most of the duplication of Origin code comes in Chapter 7 in that
>> book. There appear to be no references to Origin in that chapter
>> (based on searching through the book in Amazon).
>>
>> The IndirectlyCopyable text includes unsourced quotes directly from
>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3351.pdf
>> without quotation, and the concepts* diagrams are taken from the same
>> document. Is there an attribution on the previous page that we can't
>> see from Amazon's limited preview?
> Crediting the work of others have been done in the book as mentioned
> in the links below:
> Preface :
> http://www.algocoders.com/sites/default/files/preface_foa_revised.pdf
> Acknowledgement :
> http://www/algocoders.com/sites/default/files/acknowledgement_foa.pdf
> Table of Contents :
> http://www.algocoders.com/sites/default/files/toc_foa_revised.pdf
>
> Chapter 3 :
> http://www.algocoders.com/sites/default/files/chapter3_foa.pdf
> Chapter 11 :
> http://www.algocoders.com/sites/default/files/chapter11_foa.pdf
>
> We have avoided repetitive mention of original sources in respective
> chapters to let not the content be littered with these details again.
> Please let us know if we need to attribute in respective chapters too,
> we would like to work on it.
> Your feedback will be really helpful to guide us as a corrective measure.
>
> Looking forward for suggestions,
>
> Cheers,
> Algocoders
>
Only the last link for Chapter 11 actually works and there aren't any acknowledgements presented in that pdf.
-- Bill ------------------------------ Message: 2 Date: Mon, 4 Feb 2013 19:46:54 +0000 From: Adlai Shawareb <adlai_at_[hidden]> To: "boost-users_at_[hidden]" <boost-users_at_[hidden]> Subject: [Boost-users] How can I free memory allocated when deserializing with boost::archive::text_iarchive Message-ID: <842DD0CD91745A48B9355924E2CF0BEA114FEF3D_at_VYTRONUS-SBS.vytronus.local> Content-Type: text/plain; charset="us-ascii" 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. -------------- next part -------------- HTML attachment scrubbed and removed ------------------------------ Message: 3 Date: Mon, 4 Feb 2013 14:58:49 -0500 From: Nat Linden <nat_at_[hidden]> To: boost-users_at_[hidden] Subject: Re: [Boost-users] in IOS, thread_info object is being destructed before the thread finishes executing Message-ID: <CAKQaxCYQ2rDg78HEAxruya5E-8q6z-sw1jAi=G8eh_owpx4qpA_at_[hidden]> Content-Type: text/plain; charset=ISO-8859-1 On Mon, Feb 4, 2013 at 7:38 AM, Andy Weinstein <andyw_at_[hidden]> wrote: > This seems to happen as a result of the smart pointer reaching a zero count, > even though it is obviously still > in scope in the thread_proxy function which creates it and runs the > requested function in the thread. I feel obliged to mention a likely scenario in which a shared_ptr's count can reach zero prematurely, namely when multiple shared_ptrs are created from the same raw (native) pointer, e.g. Object* myobj = new Object(); shared_ptr<Object> sp1(myobj); shared_ptr<Object> sp2(myobj); sp1's count will be 1, as will sp2's. When either shared_ptr's count goes to zero, myobj will be destroyed, even if the other shared_ptr is still "live." > I should also note that when we did catch this happening the trap, we saw > the destructor for > ~shared_count appear twice consecutively on the stack in Xcode source. Very > doubleweird. Multiple shared_count instances make me suspicious of a scenario like the above. ------------------------------ Message: 4 Date: Mon, 4 Feb 2013 15:08:14 -0500 (EST) From: Jeremiah Willcock <jewillco_at_[hidden]> To: boost-users_at_[hidden] Subject: Re: [Boost-users] Undirected version of dijkstra shortest path on directed graph. Message-ID: <alpine.LRH.2.03.1302041507360.50272_at_[hidden]> Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed On Mon, 4 Feb 2013, Jupp Tscheak wrote: > Hello BGL specialists. > > Is it possible to use an undirected version of dijkstra shortest path function on an adjacency_list which Directed > template parameter is set to bidirectional? Yes, as long as the edge weights are the same in both directions. If the weights match, the directed Dijkstra's algorithm will produce the same effect as the undirected one. -- Jeremiah Willcock ------------------------------ Message: 5 Date: Mon, 4 Feb 2013 20:09:11 +0000 (UTC) From: Algocoders <algocoders_at_[hidden]> To: boost-users_at_[hidden] Subject: Re: [Boost-users] Crediting the Work of Others Message-ID: <loom.20130204T210248-956_at_[hidden]> Content-Type: text/plain; charset=us-ascii Bill Buklis <boostusr <at> pbjzone.com> writes: > Only the last link for Chapter 11 actually works and there aren't any > acknowledgements presented in that pdf. Fresh links are : ----------------------------------------- Foundation of Algorithms in C++11 Volume 1(Third Edition) : Using and Extending C++11, Boost and Beyond Table of Contents http://algocoders.com/sites/default/files/toc_foa_third_edition.pdf Sample Chapter 7 (Type Functions) http://algocoders.com/sites/default/files/chapter7_foa_third_edition.pdf License Information http://algocoders.com/sites/default/files/license_foa_third_edition.pdf ----------------------------------------- C++11 Algorithms Volume 1(Second Edition) : Using and Extending C++11, Boost and Beyond Table of Contents : http://www.algocoders.com/sites/default/files/toc_algo_2nd.pdf Sample Chapter 1(Simulating for-loop iteration) http://www.algocoders.com/sites/default/files/chap1_algo_2nd.pdf --------------------------------------------- For more details, please visit: http://www.algocoders.com/article/books Cheers, Algocoders ------------------------------ Message: 6 Date: Mon, 04 Feb 2013 15:24:08 -0500 From: Tim Moore <tim_at_[hidden]> To: <boost-users_at_[hidden]> Subject: Re: [Boost-users] How can I free memory allocated when deserializing with boost::archive::text_iarchive Message-ID: <c9cb14bbc5ce4d352ef0caea7137b1ba_at_[hidden]> Content-Type: text/plain; charset=UTF-8; format=flowed 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 ------------------------------ Message: 7 Date: Mon, 4 Feb 2013 16:04:44 -0500 From: Christian Henning <chhenning_at_[hidden]> To: boost-users_at_[hidden] Subject: [Boost-users] [mpl::integral_c] Compiler Error with Visual Studio 2010 Message-ID: <CAOayk6ffrypXcHUy3L=CERm2p316BbysGp++oPHrBUssuzTUhw_at_[hidden]> Content-Type: text/plain; charset=ISO-8859-1 Hi there, shouldn't the following work: #include <boost\gil\gil_all.hpp> using namespace std; using namespace boost; int main() { typedef mpl::integral_c< unsigned char , numeric_limits< unsigned char >::max() > my_max_value_t; return 0; } Visual Studio 2010 gives me: error C2975: 'N' : invalid template argument for 'boost::mpl::integral_c', expected compile-time constant expression I'm a little surprised that this isn't working. Thanks, Christian ------------------------------ Message: 8 Date: Mon, 4 Feb 2013 14:11:18 -0700 From: Nathan Crookston <nathan.crookston_at_[hidden]> To: boost-users_at_[hidden] Subject: Re: [Boost-users] [mpl::integral_c] Compiler Error with Visual Studio 2010 Message-ID: <CAMb0s=1eg-2q=52M+zFJdNqgUDKGDDqoTep54AWxb76gUQ3WQQ_at_[hidden]> Content-Type: text/plain; charset="iso-8859-1" Hi Christian, Christian Henning wrote: > Hi there, > > shouldn't the following work: > > #include <boost\gil\gil_all.hpp> > > using namespace std; > using namespace boost; > > int main() > { > typedef mpl::integral_c< unsigned char > , numeric_limits< unsigned char >::max() > > my_max_value_t; > > > return 0; > } > The good news is, I think it should work in the future when constexpr is more widely available. On compilers that aren't there yet, you need to use something with a static constant instead. Try: #include <boost/gil/gil_all.hpp> #include <boost/integer_traits.hpp> using namespace std; using namespace boost; int main() { typedef mpl::integral_c< unsigned char , integer_traits< unsigned char >::const_max > my_max_value_t; return 0; } HTH, Nate -------------- next part -------------- HTML attachment scrubbed and removed ------------------------------ Subject: Digest Footer _______________________________________________ Boost-users mailing list Boost-users_at_[hidden] http://lists.boost.org/mailman/listinfo.cgi/boost-users ------------------------------ End of Boost-users Digest, Vol 3349, Issue 6 ********************************************
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