<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:57:17 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>[JAVA-2460] Memory leaks when using NettyStream and CommandListener</title>
                <link>https://jira.mongodb.org/browse/JAVA-2460</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;I found some strange behaviour when NettyStream is used in async driver with a CommandListener configured. See next code example: &lt;a href=&quot;https://gist.github.com/jamel/957aab95a8385ef43768f378fb405d25&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://gist.github.com/jamel/957aab95a8385ef43768f378fb405d25&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There I enabled high level of Netty resource leak detector to see any problems with resource leakage. When line &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;.addCommandListener(new NopCommandListener())&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt; is commented all works just fine (see normal_run.log). But when that line is uncommented resource leak detector found some leaks (see buggy_run.log).&lt;/p&gt;

&lt;p&gt;After playing with this bug a little bit I found that root cause of these leaks is  &lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/blob/master/driver-core/src/main/com/mongodb/connection/ByteBufBsonDocument.java&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;ByteBufBsonDocument&lt;/a&gt; class. When instance of this class is &lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/blob/94780bc8b72c62d9bc09beaa9ac62b942debab5f/driver-core/src/main/com/mongodb/connection/CommandProtocol.java#L190-L191&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;created&lt;/a&gt; it takes ownership of given buffer (because &lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/blob/79a6e9366139a40129015c041f1bc25aad784343/driver-core/src/main/com/mongodb/connection/ByteBufBsonDocument.java#L78&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;bsonOutput.getByteBuffers()&lt;/a&gt; increments reference counter in each returning sub buffer). Unfortunately ByteBufBsonDocument class never releases its buffer and currently there is no way to do that.&lt;/p&gt;</description>
                <environment></environment>
        <key id="360726">JAVA-2460</key>
            <summary>Memory leaks when using NettyStream and CommandListener</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</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="ross@mongodb.com">Ross Lawley</assignee>
                                    <reporter username="jamel">Sergey Polovko</reporter>
                        <labels>
                    </labels>
                <created>Fri, 3 Mar 2017 18:37:20 +0000</created>
                <updated>Thu, 14 Sep 2023 19:29:32 +0000</updated>
                            <resolved>Fri, 28 Apr 2017 15:16:23 +0000</resolved>
                                    <version>3.4.2</version>
                                    <fixVersion>3.5.0</fixVersion>
                                    <component>Async</component>
                                        <votes>0</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="1871498" author="kojilin" created="Mon, 23 Apr 2018 16:06:48 +0000"  >&lt;p&gt;ok, I created &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-2839&quot; title=&quot;Memory leaks when using NettyStream and CommandListener&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-2839&quot;&gt;&lt;del&gt;JAVA-2839&lt;/del&gt;&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1871492" author="jeff.yemin" created="Mon, 23 Apr 2018 16:01:57 +0000"  >&lt;p&gt;Hi, &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=kojilin&quot; class=&quot;user-hover&quot; rel=&quot;kojilin&quot;&gt;kojilin&lt;/a&gt; can you open up a new bug for the issue you&apos;re seeing?  &lt;/p&gt;

&lt;p&gt;Thanks,&lt;br/&gt;
Jeff&lt;/p&gt;</comment>
                            <comment id="1871475" author="kojilin" created="Mon, 23 Apr 2018 15:51:25 +0000"  >&lt;p&gt;Hi I met this problem even upgrade to 3.6.3&lt;br/&gt;
When we use command listener, I found our code will use ByteBufBsonDocument#createList at &lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/blob/0aa2ec20d5215c0ac727602dd2cd891c22c69ba8/driver-core/src/main/com/mongodb/connection/ByteBufBsonDocument.java#L43&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/blob/0aa2ec20d5215c0ac727602dd2cd891c22c69ba8/driver-core/src/main/com/mongodb/connection/ByteBufBsonDocument.java#L43&lt;/a&gt;&lt;br/&gt;
and maybe duplicate here needs to be release?&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/blob/0aa2ec20d5215c0ac727602dd2cd891c22c69ba8/driver-core/src/main/com/mongodb/connection/ByteBufBsonDocument.java#L51&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/blob/0aa2ec20d5215c0ac727602dd2cd891c22c69ba8/driver-core/src/main/com/mongodb/connection/ByteBufBsonDocument.java#L51&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1560257" author="xgen-internal-githook" created="Fri, 28 Apr 2017 15:16:12 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;rozza&apos;, u&apos;name&apos;: u&apos;Ross Lawley&apos;, u&apos;email&apos;: u&apos;ross.lawley@gmail.com&apos;}
&lt;p&gt;Message: Ensure that the ByteBufferBsonOutput releases all on close&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-2460&quot; title=&quot;Memory leaks when using NettyStream and CommandListener&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-2460&quot;&gt;&lt;del&gt;JAVA-2460&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/9c3d9fa66ffddb0a8bab03519fc0048987b2f422&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/9c3d9fa66ffddb0a8bab03519fc0048987b2f422&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1558475" author="ross@10gen.com" created="Wed, 26 Apr 2017 17:20:15 +0000"  >&lt;p&gt;PR: &lt;a href=&quot;https://github.com/rozza/mongo-java-driver/pull/191&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/rozza/mongo-java-driver/pull/191&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1556974" author="ross@10gen.com" created="Tue, 25 Apr 2017 09:29:56 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jamel&quot; class=&quot;user-hover&quot; rel=&quot;jamel&quot;&gt;jamel&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;Thank you for the ticket and gist that reproduces the error, also apologies for the lack of response. Rest assured this issue is on our radar and we&apos;ll update once we have determined a suitable fix.&lt;/p&gt;

&lt;p&gt;Ross&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="532590">JAVA-2839</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hsqoq7:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="1686">JVM Sprint 39</customfieldvalue>

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