[Boost-bugs] [Boost C++ Libraries] #9062: boost deserialization memory leak

Subject: [Boost-bugs] [Boost C++ Libraries] #9062: boost deserialization memory leak
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-08-29 11:04:38


#9062: boost deserialization memory leak
------------------------------+---------------------------
 Reporter: ylzhang@… | Owner: ramey
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: serialization
  Version: Boost 1.41.0 | Severity: Problem
 Keywords: |
------------------------------+---------------------------
 While using boost to serialize/deserialize, valgrind reports that there
 are memory leaks about it:
 =23011== 722 (448 direct, 274 indirect) bytes in 2 blocks are definitely
 lost in loss record 72 of 83
 ==23011== at 0x4C27C8E: operator new(unsigned long)
 (vg_replace_malloc.c:261)
 ==23011== by 0x4CCE77:
 boost::archive::detail::pointer_iserializer<boost::archive::binary_iarchive,
 BG3pBidV2>::load_object_ptr(boost::archive::detail::basic_iarchive&,
 void*&, unsigned int) const (iserializer.hpp:229)
 ==23011== by 0x4E658C1:
 boost::archive::detail::basic_iarchive::load_pointer(void*&,
 boost::archive::detail::basic_pointer_iserializer const*) (in /usr/lib64
 /libboost_serialization-mt.so.5)
 ==23011== by 0x4D3C58:
 boost::archive::detail::iserializer<boost::archive::binary_iarchive,
 boost::shared_ptr<BG3pBidV2>
>::load_object_data(boost::archive::detail::basic_iarchive&, void*,
 unsigned int) const (iserializer.hpp:486)
 ==23011== by 0x4E65354:
 boost::archive::detail::basic_iarchive::load_object(void*,
 boost::archive::detail::basic_iserializer const&) (in /usr/lib64
 /libboost_serialization-mt.so.5)
 ==23011== by 0x4DB279:
 boost::archive::detail::iserializer<boost::archive::binary_iarchive,
 std::vector<boost::shared_ptr<BG3pBidV2>,
 std::allocator<boost::shared_ptr<BG3pBidV2> > >
>::load_object_data(boost::archive::detail::basic_iarchive&, void*,
 unsigned int) const (iserializer.hpp:363)
 ==23011== by 0x4E65354:
 boost::archive::detail::basic_iarchive::load_object(void*,
 boost::archive::detail::basic_iserializer const&) (in /usr/lib64
 /libboost_serialization-mt.so.5)
 ==23011== by 0x4C484B:
 boost::archive::detail::iserializer<boost::archive::binary_iarchive,
 BGRequestV2>::load_object_data(boost::archive::detail::basic_iarchive&,
 void*, unsigned int) const (iserializer.hpp:363)
 ==23011== by 0x4E65354:
 boost::archive::detail::basic_iarchive::load_object(void*,
 boost::archive::detail::basic_iserializer const&) (in /usr/lib64
 /libboost_serialization-mt.so.5)

 And here is my code, very simple:
     template <class T>
     int deserialize(T& bidObj, const char *filename)
     {
         if (!filename) {
             std::cerr << "file name is empty"<<std::endl;
             return ERROR;
         }

         std::ifstream ifs(filename);
         assert(ifs.good());

         //boost::archive::text_iarchive iar(ifs);
         boost::archive::binary_iarchive iar(ifs);

         iar >> bidObj; // object deserialized

         return ::OK;
     }

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/9062>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:14 UTC