Boost C++ Libraries: Ticket #3412: Memory leak in BOOST_CLASS_EXPORT registration https://svn.boost.org/trac10/ticket/3412 <p> 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. </p> <pre class="wiki">#include &lt;stdio.h&gt; #include &lt;tchar.h&gt; #include &lt;crtdbg.h&gt; #include &lt;boost/archive/binary_oarchive.hpp&gt; #include &lt;boost/serialization/export.hpp&gt; class Base { friend class boost::serialization::access; template&lt;class Archive&gt; void serialize(Archive &amp; ar, const unsigned int version) { } virtual void vTest() { } }; class Level1 : public Base { friend class boost::serialization::access; template&lt;class Archive&gt; void serialize(Archive &amp; ar, const unsigned int version) { ar &amp; boost::serialization::base_object&lt;Base&gt;(*this); } }; class Level2 : public Level1 { friend class boost::serialization::access; template&lt;class Archive&gt; void serialize(Archive &amp; ar, const unsigned int version) { ar &amp; boost::serialization::base_object&lt;Level1&gt;(*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; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3412 Trac 1.4.3 Robert Ramey Sun, 11 Oct 2009 21:11:05 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3412#comment:1 https://svn.boost.org/trac10/ticket/3412#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> I've fixed this on my own machine. </p> <p> I don't know if it will get uploaded/tested in time for inclusion in 1.41. </p> <p> Thanks for providing a good test case. It was very helpful. </p> <p> Robert Ramey </p> Ticket Runar Undheim <r.undheim@…> Wed, 25 Nov 2009 09:24:04 GMT attachment set https://svn.boost.org/trac10/ticket/3412 https://svn.boost.org/trac10/ticket/3412 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">MemLeakSerialization.cpp</span> </li> </ul> Ticket Runar Undheim <r.undheim@…> Wed, 25 Nov 2009 09:48:32 GMT status, version changed; resolution deleted https://svn.boost.org/trac10/ticket/3412#comment:2 https://svn.boost.org/trac10/ticket/3412#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost 1.40.0</span> → <span class="trac-field-new">Boost 1.41.0</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> <p> Some of the memory leaks are gone, but there are still some memory leaks left in the registration code. I have updated the example with Level3 and Level4 and get new leaks. See attached file. To make the code easier to debug it is possible to comment out BOOST_CLASS_EXPORT(Level4). Then you only get one leak. </p> Ticket Robert Ramey Sat, 28 Nov 2009 18:58:41 GMT <link>https://svn.boost.org/trac10/ticket/3412#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3412#comment:3</guid> <description> <p> I've found this and fixed on my own machine. It will be checked into the trunk shortly. </p> <p> I don't think I could have tracked this down without your test. </p> <p> Robert Ramey </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Sat, 28 Nov 2009 19:00:08 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/3412#comment:4 https://svn.boost.org/trac10/ticket/3412#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket