<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:24:13 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[SERVER-10843] example tutorial (valgrind memleak checkable ) memory leak</title>
                <link>https://jira.mongodb.org/browse/SERVER-10843</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;1 when tutotial exit,heap memleak.&lt;/p&gt;

&lt;p&gt;2 some leak information.&lt;br/&gt;
==2254== HEAP SUMMARY:&lt;br/&gt;
==2254==     in use at exit: 744 bytes in 19 blocks&lt;br/&gt;
==2254==   total heap usage: 483 allocs, 464 frees, 137,635 bytes allocated&lt;/p&gt;

&lt;p&gt;3 I have appended the valgrind detail information file.&lt;/p&gt;</description>
                <environment>CentOS release 6.4 (Final)</environment>
        <key id="91068">SERVER-10843</key>
            <summary>example tutorial (valgrind memleak checkable ) memory leak</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="andrew.morrow@mongodb.com">Andrew Morrow</assignee>
                                    <reporter username="guoxue.duan">duanguoxue</reporter>
                        <labels>
                            <label>driver</label>
                            <label>memory-leak</label>
                    </labels>
                <created>Mon, 23 Sep 2013 02:26:13 +0000</created>
                <updated>Wed, 10 Dec 2014 23:12:03 +0000</updated>
                            <resolved>Wed, 11 Dec 2013 20:28:26 +0000</resolved>
                                    <version>2.4.0</version>
                                                    <component>Internal Client</component>
                                        <votes>0</votes>
                                    <watches>6</watches>
                                                                                                                <comments>
                            <comment id="469492" author="acm" created="Wed, 11 Dec 2013 20:28:26 +0000"  >&lt;p&gt;I&apos;m marking this as works as designed, since these are one-shot leaks and are intentional, for ow.&lt;/p&gt;</comment>
                            <comment id="460813" author="acm" created="Sat, 23 Nov 2013 16:12:13 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=guoxue.duan&quot; class=&quot;user-hover&quot; rel=&quot;guoxue.duan&quot;&gt;guoxue.duan&lt;/a&gt; As I mentioned earlier in the thread, there are some allocations that we do not free related to the initialization of the library. Over time, we hope to reduce these. However, these leaks are one time only: they will not contribute to long term memory growth of the process, like a leak that was triggered on every invocation of the API.&lt;/p&gt;

&lt;p&gt;Your best option is to add a valgrind suppression to ignore these errors.&lt;/p&gt;</comment>
                            <comment id="457346" author="guoxue.duan" created="Sat, 16 Nov 2013 09:03:01 +0000"  >&lt;p&gt;execution script&lt;/p&gt;
&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;valgrind  --leak-check=full  --log-file=valgind_master_11_16.log ./tutorial&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;</comment>
                            <comment id="457345" author="guoxue.duan" created="Sat, 16 Nov 2013 09:00:30 +0000"  >&lt;p&gt;Hi,&lt;br/&gt;
I&apos;ve retested the shared library of the &quot;mongoclient.so&quot; ,test can well execute ,but still have memory leak related to the &quot;GlobalInitializers&quot;.&lt;/p&gt;

&lt;p&gt;I have track the master mongoclient code. We process the global &quot;initializer&quot;  that is not very good.&lt;/p&gt;
&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;    void ProcessInfo::initializeSystemInfo() {&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;        if (systemInfo == NULL) {&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;            systemInfo = new SystemInfo();&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;        }&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;    }&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;
&lt;p&gt;where and how to delete the new class objection. If delete the obj may generate a new race condition.&lt;br/&gt;
I attached my testing valgrind logfile &quot;valgind_master_11_16.log&quot;&lt;/p&gt;

&lt;p&gt;Hope my testing can give some help for the issue.&lt;/p&gt;

&lt;p&gt;mongo on branch  of master&lt;br/&gt;
commit 9766387567e366e167835880818369cee7f8d42d&lt;/p&gt;</comment>
                            <comment id="452373" author="acm" created="Wed, 6 Nov 2013 17:04:29 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=guoxue.duan&quot; class=&quot;user-hover&quot; rel=&quot;guoxue.duan&quot;&gt;guoxue.duan&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;I&apos;ve reproduced your issue; thanks for bringing it to our attention. In the meantime, I think you can work around the problem by using the shared library version of the client driver, rather than the static library. If you add &lt;tt&gt;&amp;#45;&amp;#45;sharedclient&lt;/tt&gt; to your client driver build line, you should be able to link in exactly the same way but pick up the dynamic library and avoid this issue. Please let me know if that works for you while we look into resolving the issue in the static library.&lt;/p&gt;

&lt;p&gt;Thanks,&lt;br/&gt;
Andrew&lt;/p&gt;</comment>
                            <comment id="452244" author="guoxue.duan" created="Wed, 6 Nov 2013 13:59:32 +0000"  >&lt;p&gt;Thanks to you correct my error using &quot;scans&quot;,but it accurately work for building &quot;libmongoclient.a&quot;(I read the SConstruct to guess how to using).&lt;/p&gt;

&lt;p&gt;I have confirm to re-test my app using the below steps:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;scons --use-system-boost --extrapath=/usr/local --full --prefix=$HOME/mongo-driver-install install-mongoclient&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;I also build the &quot;mongo/client/example/tutorial.cpp&quot; example app, but(my test and example tutorial.cpp) have the same error. &lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;g++ -g tutorial.cpp -I/root/mongo-driver-install/include/  -pthread -lpthread -lboost_thread -lboost_filesystem -lboost_program_options -lboost_system -lmongoclient -o tutorial -L/root/mongo-driver-install/lib/&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;font color=&quot;red&quot;&gt;Error info:&lt;/font&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;failed to initialize the client driver: BadValue default&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;I hope you could try the mongo example  &quot;tutorial.cpp&quot;,you will be get answer.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;mongo on branch master&lt;br/&gt;
commit c2d573d82da78c4bd897029670189e300f3f59ee&lt;/p&gt;&lt;/blockquote&gt;</comment>
                            <comment id="451827" author="acm" created="Tue, 5 Nov 2013 20:21:53 +0000"  >&lt;p&gt;The --use-system-boost option does not take an argument, so I&apos;m puzzled by how this is working for you to build. The proper argument to specify the search path for boost is --extrapath.&lt;/p&gt;

&lt;p&gt;So your build line would look like:&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;scons --use-system-boost --extrapath=/usr/local&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;In addition, you probably want to install the client library and headers somewhere, then build your application. So if you were installing to $HOME/mongo-driver-install, your invocation would be:&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;scons --use-system-boost --extrapath=/usr/local --full --prefix=$HOME/mongo-driver-install install-mongoclient&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;You would then set your application build to use $HOME/mongo-driver-install/include and $HOME/mongo-driver-install/lib for include and library search paths as well.&lt;/p&gt;

&lt;p&gt;Finally, please note that you can also build the driver a shared library, by passing the --sharedclient flag.&lt;/p&gt;

&lt;p&gt;As for the crash you experienced, it is hard to debug without some additional information. If possible can you show the exact code you used to call mongo::client::initialize, and any code that ran earlier in main? Ideally, just reduce your mainline to the shortest program that demonstrates the issue and post it here.&lt;/p&gt;

&lt;p&gt;Thanks,&lt;br/&gt;
Andrew&lt;/p&gt;</comment>
                            <comment id="451446" author="guoxue.duan" created="Tue, 5 Nov 2013 10:01:48 +0000"  >&lt;p&gt;Hi, &lt;br/&gt;
I have clone the github master and using &lt;blockquote&gt;&lt;p&gt;&quot;scons  --use-system-boost=/usr/local/include/ mongoclient&quot;&lt;/p&gt;&lt;/blockquote&gt; compiling the &quot;libmongoclient.a&quot; ok.&lt;/p&gt;


&lt;p&gt;But execute my test app.&lt;br/&gt;
Reporting the error info:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;failed to initialize the client driver: BadValue default &lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;I and  some &quot;printf  log info to mongoclient code&quot; find in function &quot;recursiveTopSort &quot;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;if ((*visitedNodeNames).count(currentNode.first))&lt;br/&gt;
            return Status::OK();&lt;br/&gt;
        if (!currentNode.second.fn)&lt;br/&gt;
            return Status(ErrorCodes::BadValue, currentNode.first);&lt;br/&gt;
        inProgressNodeNames-&amp;gt;push_back(currentNode.first);&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;When &lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;currentNode.first = &quot;default&quot; &lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;but &lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;currentNode.second.fn =NULL&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;May be I have a error using the library.&lt;/p&gt;</comment>
                            <comment id="451000" author="acm" created="Mon, 4 Nov 2013 17:42:01 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=guoxue.duan&quot; class=&quot;user-hover&quot; rel=&quot;guoxue.duan&quot;&gt;guoxue.duan&lt;/a&gt; -&lt;/p&gt;

&lt;p&gt;You might want to re-test with the latest code from master. We have just added new API&apos;s to explicitly manage the client driver lifecycle (see mongo/client/init.h). You can probably use these methods to successfully arrange clean driver shutdown, in particular, destroying the BackgroundJob responsible for running PeriodicTasks.&lt;/p&gt;

&lt;p&gt;Can you please update your test to use these new APIs, re-run your checks, and post the results back?&lt;/p&gt;

&lt;p&gt;Thanks,&lt;br/&gt;
Andrew&lt;/p&gt;</comment>
                            <comment id="443524" author="guoxue.duan" created="Sun, 20 Oct 2013 09:14:36 +0000"  >&lt;p&gt;Hi, this is my test application and valgrind report. Hope can help you.&lt;/p&gt;</comment>
                            <comment id="443523" author="guoxue.duan" created="Sun, 20 Oct 2013 09:12:55 +0000"  >&lt;p&gt;build command:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;g++ -g tutorial.cpp  -pthread -lmongoclient -lpthread -lboost_thread -lboost_filesystem -lboost_program_options -lboost_system -o tutorial -I /root/mongo-cxx-driver-v2.4/src/ -L /root/mongo-cxx-driver-v2.4/build/&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;running command:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;valgrind --log-file=valgind_l_r_2.4.6_10-20.log  --leak-check=full ./tutorial&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&quot;tutorial.cpp&quot; is the modified test application.&lt;/p&gt;

&lt;p&gt;If i modified my cxx driver with the github two pull request( &lt;a href=&quot;https://github.com/mongodb/mongo/pull/497&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/pull/497&lt;/a&gt;  ) ,I will get a clean valgind report.&lt;/p&gt;

&lt;p&gt;&lt;font color=&quot;red&quot;&gt;&lt;br/&gt;
And I think the &quot;DBConnectionPool&quot;  memory leak is obvious error. &quot;BackgroundJob&quot; is don&apos;t free the global variable obj may have a difficult.(So MUST confirm no other influence) &lt;/font&gt;&lt;/p&gt;</comment>
                            <comment id="442042" author="guoxue.duan" created="Thu, 17 Oct 2013 03:43:11 +0000"  >&lt;p&gt;Hi ,&lt;br/&gt;
I think the static initialization of the library also must be free,which is  very important too.May be We  use a library give a  function to initialize the static area and release function to free static memory(I also see in libproto libgtest ,etc).&lt;/p&gt;

&lt;p&gt;If I use &quot;DBConnectionPool&quot; as a local variable. I will have a continual grow memory leak.&lt;/p&gt;

&lt;p&gt;Additional  I retest the &quot;no-show-reachable=yes&quot; situations and I reconstruct a memory leak application.&lt;/p&gt;

&lt;p&gt;&quot;valgrind --leak-check=full --log-file=val2.4.6_no-show-reachable.log  ./test_mg_db 128&quot;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;==3631== HEAP SUMMARY:&lt;br/&gt;
==3631==     in use at exit: 3,320 bytes in 118 blocks&lt;br/&gt;
==3631==   total heap usage: 929 allocs, 811 frees, 189,172 bytes allocated&lt;br/&gt;
==3631==&lt;br/&gt;
==3631== 40 bytes in 1 blocks are definitely lost in loss record 14 of 19&lt;br/&gt;
==3631==    at 0x4A075BC: operator new(unsigned long) (vg_replace_malloc.c:298)&lt;br/&gt;
==3631==    by 0x48AF1D: mongo::BackgroundJob::BackgroundJob(bool) (in /root/search/MTSearch/dba/test_mg_db)&lt;br/&gt;
==3631==    by 0x447CFD: global constructors keyed to dbclient_rs.cpp (in /root/search/MTSearch/dba/test_mg_db)&lt;br/&gt;
==3631==    by 0x4AE495: ??? (in /root/search/MTSearch/dba/test_mg_db)&lt;br/&gt;
==3631==    by 0x4108EA: ??? (in /root/search/MTSearch/dba/test_mg_db)&lt;br/&gt;
==3631==&lt;br/&gt;
==3631== 1,600 bytes in 100 blocks are definitely lost in loss record 19 of 19&lt;br/&gt;
==3631==    at 0x4A075BC: operator new(unsigned long) (vg_replace_malloc.c:298)&lt;br/&gt;
==3631==    by 0x4287C8: mongo::DBConnectionPool::DBConnectionPool() (in /root/search/MTSearch/dba/test_mg_db)&lt;br/&gt;
==3631==    by 0x411C16: main (test_mg_db.cc:51)&lt;br/&gt;
==3631==&lt;br/&gt;
==3631== LEAK SUMMARY:&lt;br/&gt;
==3631==    definitely lost: 1,640 bytes in 101 blocks&lt;br/&gt;
==3631==    indirectly lost: 0 bytes in 0 blocks&lt;br/&gt;
==3631==      possibly lost: 0 bytes in 0 blocks&lt;br/&gt;
==3631==    still reachable: 1,680 bytes in 17 blocks&lt;br/&gt;
==3631==         suppressed: 0 bytes in 0 blocks&lt;/p&gt;&lt;/blockquote&gt;</comment>
                            <comment id="433896" author="acm" created="Tue, 1 Oct 2013 15:28:27 +0000"  >&lt;p&gt;Hi -&lt;/p&gt;

&lt;p&gt;Thanks for re-testing with 2.4.6.&lt;/p&gt;

&lt;p&gt;The reports in the log are appearing because you have run valgrind with --show-reachable=yes. This is memory that was allocated, but is still referenced, therefore it has not been leaked. I believe that all of the memory listed in your report originates from the static initialization of the library. While perhaps not ideal that this memory is never reclaimed, the adverse consequences of this sort of behavior are minimal: the allocations are not repeated, therefore the memory footprint will not grow over time, which is typically the worry in a memory leak.&lt;/p&gt;

&lt;p&gt;As to the changes in the pull request: First, you don&apos;t need to check a pointer to be non-NULL before deleting it. It is safe to call delete on a NULL pointer and it is specified to be a no-op. Second, you do not need to set the variable to NULL after deleting it, especially when operating on a member variable in a destructor, since the lifetime of the member variable terminates with the object, so the effect of the assignment to NULL is unobservable.&lt;/p&gt;

&lt;p&gt;To demonstrate that there is indeed a memory leak, you will need to provide a program that causes the memory utilization of the process using libmongoclient to grow without bound. Please let me know if you have any further questions. Obviously, we want to ensure that using libmongoclient does not cause unbounded memory utilization in client programs.&lt;/p&gt;

&lt;p&gt;Thanks,&lt;br/&gt;
Andrew&lt;/p&gt;</comment>
                            <comment id="430223" author="guoxue.duan" created="Tue, 24 Sep 2013 06:06:59 +0000"  >&lt;p&gt;1 recompiling the cxx driver 2.4.6  and my tutorial app.&lt;br/&gt;
2 I have re-test the same case(valgrind  --leak-check=full --show-reachable=yes  --log-file=valgind_l_r_2.4.6.log ./tutorial).&lt;/p&gt;


&lt;p&gt;More ,I find some issues,and reading the github  mainline code,also have the same bugs.&lt;/p&gt;

&lt;p&gt;Some memleak commit a pull request(&lt;a href=&quot;https://github.com/mongodb/mongo/pull/497&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/pull/497&lt;/a&gt; ),but some I don&apos;t kown how to repair.&lt;br/&gt;
Example: &lt;blockquote&gt;
&lt;p&gt;Ports&amp;amp; ports = *(new Ports());&lt;br/&gt;
DiagStr&amp;amp; _hostNameCached = *(new DiagStr); &lt;br/&gt;
static ErrorInfo* okInfo = new ErrorInfo(ErrorCodes::OK, &quot;&quot;, 0);&lt;/p&gt;&lt;/blockquote&gt;&lt;/p&gt;</comment>
                            <comment id="429726" author="acm" created="Mon, 23 Sep 2013 14:15:50 +0000"  >&lt;p&gt;Thank you for the report. A few comments:&lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;You are using 2.4.0, which has some known issues. Can you please re-test with the most recent 2.4 release, 2.4.6, and re-post your results?&lt;/li&gt;
	&lt;li&gt;All but one of the items reported by valgrind are identified as &apos;still reachable&apos;, so these are not memory leaks.&lt;/li&gt;
	&lt;li&gt;All of these memory regions are owned by static initializers, so these allocations will not be repeated.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;I do agree, however, that it is important for our library to be as clean as possible under valgrind so that we don&apos;t cause false positives in applications that are attempting to be valgrind clean. So I am interested in our repairing the &apos;definitely lost&apos; region if this behavior is reproduced with the 2.4.6 driver.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                            <outwardlinks description="depends on">
                                        <issuelink>
            <issuekey id="51953">SERVER-7217</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="32751" name="tutorial.cpp" size="2628" author="guoxue.duan" created="Sun, 20 Oct 2013 09:14:36 +0000"/>
                            <attachment id="32659" name="val2.4.6_no-show-reachable.log" size="1874" author="guoxue.duan" created="Thu, 17 Oct 2013 03:43:55 +0000"/>
                            <attachment id="31670" name="valgind_l_r.log" size="16841" author="guoxue.duan" created="Mon, 23 Sep 2013 02:26:13 +0000"/>
                            <attachment id="31720" name="valgind_l_r_2.4.6.log" size="14262" author="guoxue.duan" created="Tue, 24 Sep 2013 06:06:59 +0000"/>
                            <attachment id="32750" name="valgind_l_r_2.4.6_10-20.log" size="1997" author="guoxue.duan" created="Sun, 20 Oct 2013 09:14:36 +0000"/>
                            <attachment id="33953" name="valgind_master_11_16.log" size="10865" author="guoxue.duan" created="Sat, 16 Nov 2013 09:03:01 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>15.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Mon, 23 Sep 2013 14:15:50 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        10 years, 10 weeks ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[<s><a href='https://jira.mongodb.org/browse/SERVER-7217'>SERVER-7217</a></s>]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>ramon.fernandez@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            10 years, 10 weeks ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10000" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Old_Backport</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10000"><![CDATA[No]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10032" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Operating System</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10020"><![CDATA[Linux]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>andrew.morrow@mongodb.com</customfieldvalue>
            <customfieldvalue>guoxue.duan</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrmftr:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrt1nb:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>83347</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10750" key="com.atlassian.jira.plugin.system.customfieldtypes:textarea">
                        <customfieldname>Steps To Reproduce</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>&lt;p&gt;1 complile mongo-cxx-2.4 driver&lt;br/&gt;
2 valgrind  --leak-check=full --show-reachable=yes  --log-file=valgind_l_r.log ./tutorial&lt;/p&gt;</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrky3z:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>