Boost C++ Libraries: Ticket #6879: Memory leak using resolve() method from basic_resolver https://svn.boost.org/trac10/ticket/6879 <p> Every time I use the resolve(), memory goes up. I have checked the latest code, it looks like the resolve() in resolver_service.hpp never call freeaddrinfo() to free the memory 'address_info' allocated by getaddrinfo(). </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6879 Trac 1.4.3 viboes Mon, 28 May 2012 17:16:25 GMT component changed; owner set https://svn.boost.org/trac10/ticket/6879#comment:1 https://svn.boost.org/trac10/ticket/6879#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">chris_kohlhoff</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">asio</span> </li> </ul> Ticket chris_kohlhoff Mon, 28 May 2012 23:24:16 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6879#comment:2 https://svn.boost.org/trac10/ticket/6879#comment:2 <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">worksforme</span> </li> </ul> <p> The freeaddrinfo() function is called automatically by the auto_addrinfo class. Please reopen this ticket if you can supply a test program that reproduces the problem, as well as details on the target platform and compiler. </p> Ticket mike.gresens@… Fri, 16 Jun 2017 14:01:35 GMT status, version changed; resolution deleted https://svn.boost.org/trac10/ticket/6879#comment:3 https://svn.boost.org/trac10/ticket/6879#comment:3 <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.49.0</span> → <span class="trac-field-new">Boost 1.63.0</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">worksforme</span> </li> </ul> <p> Given the following code: </p> <pre class="wiki">#include &lt;boost/asio.hpp&gt; #include &lt;iostream&gt; void test() { boost::asio::io_service service; boost::asio::ip::tcp::resolver resolver{service}; boost::asio::ip::tcp::socket socket{service}; boost::asio::ip::tcp::resolver::query query{"hessian.caucho.com", "http"}; boost::asio::connect(socket, resolver.resolve(query)); } int main() { try { test(); } catch (std::exception const&amp; exception) { std::cerr &lt;&lt; "error: " &lt;&lt; exception.what() &lt;&lt; std::endl; } return 0; } </pre><p> And running the binary with valgrind: </p> <pre class="wiki">valgrind --leak-check=full bin/gcc-7/debug/hessian-foo </pre><p> Produces these errors/warnings: </p> <pre class="wiki">==6795== Memcheck, a memory error detector ==6795== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==6795== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info ==6795== Command: bin/gcc-7/debug/hessian-foo ==6795== ==6795== ==6795== HEAP SUMMARY: ==6795== in use at exit: 5,741 bytes in 7 blocks ==6795== total heap usage: 176 allocs, 169 frees, 128,625 bytes allocated ==6795== ==6795== 4,096 bytes in 1 blocks are definitely lost in loss record 7 of 7 ==6795== at 0x4C2DB2F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==6795== by 0x406B991: ??? ==6795== by 0x40698DB: ??? ==6795== by 0x408E060: ??? ==6795== by 0x406ADDC: ??? ==6795== by 0x58E916E: gaih_inet.constprop.5 (getaddrinfo.c:848) ==6795== by 0x58EB447: getaddrinfo (getaddrinfo.c:2391) ==6795== by 0x111D1F: boost::asio::detail::socket_ops::getaddrinfo(char const*, char const*, addrinfo const&amp;, addrinfo**, boost::system::error_code&amp;) (socket_ops.ipp:3240) ==6795== by 0x116255: boost::asio::detail::resolver_service&lt;boost::asio::ip::tcp&gt;::resolve(std::shared_ptr&lt;void&gt;&amp;, boost::asio::ip::basic_resolver_query&lt;boost::asio::ip::tcp&gt; const&amp;, boost::system::error_code&amp;) (resolver_service.hpp:64) ==6795== by 0x115425: boost::asio::ip::resolver_service&lt;boost::asio::ip::tcp&gt;::resolve(std::shared_ptr&lt;void&gt;&amp;, boost::asio::ip::basic_resolver_query&lt;boost::asio::ip::tcp&gt; const&amp;, boost::system::error_code&amp;) (resolver_service.hpp:113) ==6795== by 0x114627: boost::asio::ip::basic_resolver&lt;boost::asio::ip::tcp, boost::asio::ip::resolver_service&lt;boost::asio::ip::tcp&gt; &gt;::resolve(boost::asio::ip::basic_resolver_query&lt;boost::asio::ip::tcp&gt; const&amp;) (basic_resolver.hpp:102) ==6795== by 0x10CBCC: test() (foo.cpp:17) ==6795== ==6795== LEAK SUMMARY: ==6795== definitely lost: 4,096 bytes in 1 blocks ==6795== indirectly lost: 0 bytes in 0 blocks ==6795== possibly lost: 0 bytes in 0 blocks ==6795== still reachable: 1,645 bytes in 6 blocks ==6795== suppressed: 0 bytes in 0 blocks ==6795== Reachable blocks (those to which a pointer was found) are not shown. ==6795== To see them, rerun with: --leak-check=full --show-leak-kinds=all ==6795== ==6795== For counts of detected and suppressed errors, rerun with: -v ==6795== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) </pre><p> System: </p> <pre class="wiki">Linux workstation 4.10.0-22-generic #24-Ubuntu SMP Mon May 22 17:43:20 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux </pre><p> Compilers: </p> <pre class="wiki">g++ (Ubuntu 7-20170407-0ubuntu2) 7.0.1 20170407 (experimental) [trunk revision 246759] g++ (Ubuntu 6.3.0-12ubuntu2) 6.3.0 20170406 clang version 4.0.0-1ubuntu1 (tags/RELEASE_400/rc1) </pre> Ticket anonymous Sun, 25 Jun 2017 13:00:42 GMT <link>https://svn.boost.org/trac10/ticket/6879#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6879#comment:4</guid> <description> <p> same here </p> </description> <category>Ticket</category> </item> </channel> </rss>