[Boost-bugs] [Boost C++ Libraries] #3412: Memory leak in BOOST_CLASS_EXPORT registration

Subject: [Boost-bugs] [Boost C++ Libraries] #3412: Memory leak in BOOST_CLASS_EXPORT registration
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-09-07 12:00:15


#3412: Memory leak in BOOST_CLASS_EXPORT registration
-------------------------------------------------+--------------------------
 Reporter: Runar Undheim <r.undheim@…> | Owner: ramey
     Type: Bugs | Status: new
Milestone: Boost 1.41.0 | Component: serialization
  Version: Boost 1.40.0 | Severity: Problem
 Keywords: serialization memory leak |
-------------------------------------------------+--------------------------
 Added example of code that will give memory leak. The code is tested with
 MSVC-8.0. When run in debug the program will show three memory leaks. If I
 set a break point in the void_caster_shortcut constructor the function is
 run once, but the destructor is never called.

 {{{
 #include <stdio.h>
 #include <tchar.h>
 #include <crtdbg.h>


 #include <boost/archive/binary_oarchive.hpp>
 #include <boost/serialization/export.hpp>

 class Base {
   friend class boost::serialization::access;
   template<class Archive>
   void serialize(Archive & ar, const unsigned int version) { }

   virtual void vTest() { }
 };

 class Level1 : public Base {
   friend class boost::serialization::access;
   template<class Archive>
   void serialize(Archive & ar, const unsigned int version)
   { ar & boost::serialization::base_object<Base>(*this); }
 };

 class Level2 : public Level1 {
   friend class boost::serialization::access;
   template<class Archive>
   void serialize(Archive & ar, const unsigned int version)
   { ar & boost::serialization::base_object<Level1>(*this); }
 };

 BOOST_CLASS_EXPORT(Base)
 BOOST_CLASS_EXPORT(Level1)
 BOOST_CLASS_EXPORT(Level2)

 int _tmain(int argc, _TCHAR* argv[])
 {
   _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF);
   return 0;
 }

 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3412>
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:01 UTC