<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:55:46 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-1883] Using the async driver, no references should remain to a callback after it has been called back</title>
                <link>https://jira.mongodb.org/browse/JAVA-1883</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;When using the async API, we have noticed an increase in memory use when executing queries that collect a large amount of documents. A heap dump analysis shows that the connection keeps a reference to a callback, even after it has been called. As the connection itself will be pooled, this may lead to memory &quot;leak&quot; issues, especially when the connection pool is configured to a large maximum size.&lt;/p&gt;</description>
                <environment></environment>
        <key id="216143">JAVA-1883</key>
            <summary>Using the async driver, no references should remain to a callback after it has been called back</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="jeff.yemin@mongodb.com">Jeffrey Yemin</assignee>
                                    <reporter username="peterhendriks">Peter Hendriks</reporter>
                        <labels>
                    </labels>
                <created>Fri, 10 Jul 2015 15:32:22 +0000</created>
                <updated>Fri, 1 Apr 2016 20:58:51 +0000</updated>
                            <resolved>Mon, 28 Sep 2015 14:16:34 +0000</resolved>
                                    <version>3.0.0</version>
                                    <fixVersion>3.1.0</fixVersion>
                                    <component>Async</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="1055345" author="peterhendriks" created="Thu, 8 Oct 2015 14:36:51 +0000"  >&lt;p&gt;Thanks!&lt;/p&gt;</comment>
                            <comment id="1053717" author="jeff.yemin" created="Wed, 7 Oct 2015 13:01:03 +0000"  >&lt;p&gt;Released in &lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/releases/tag/r3.1.0&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;3.1.0&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1044828" author="xgen-internal-githook" created="Mon, 28 Sep 2015 14:16:16 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;jyemin&apos;, u&apos;name&apos;: u&apos;Jeff Yemin&apos;, u&apos;email&apos;: u&apos;jeff.yemin@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-1883&quot; title=&quot;Using the async driver, no references should remain to a callback after it has been called back&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-1883&quot;&gt;&lt;del&gt;JAVA-1883&lt;/del&gt;&lt;/a&gt;: Since the AsynchronousSocketChannelStream implementation provided by the JDK may store references to completion handlers long after they are no longer used, ensure that the AsynchronousSocketChannelStream completion handlers release their references to upstream handlers as soon as they are no longer needed.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/2ffdcf5d361d03754161531c5bc0408475d1df85&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/2ffdcf5d361d03754161531c5bc0408475d1df85&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1042918" author="jeff.yemin" created="Fri, 25 Sep 2015 01:07:20 +0000"  >&lt;p&gt;Hi Peter,&lt;/p&gt;

&lt;p&gt;Thanks for the detective work.&lt;/p&gt;

&lt;p&gt;The real offender here is sun.nio.ch.UnixAsynchronousSocketChannelImpl, which does not null out its references to the completion handlers after calling them.  But the driver code can work around this by nulling out its own upstream references.  So we can fix this.&lt;/p&gt;

</comment>
                            <comment id="1042624" author="peterhendriks" created="Thu, 24 Sep 2015 20:28:38 +0000"  >&lt;p&gt;@jeff.yemin: it was a bit hard to isolate the code into a small example for the find() scenario, but we ran into a different scenario doing updates/replaces, which I was able to get into a small example case. I think the two scenarios may trigger the same issue so I&apos;ve added the example to this issue.&lt;/p&gt;

&lt;p&gt;Basically, while doing updates, the parameters are captured in an UpdateRequest object by the Mongo Driver, that is used for processing the request. However, after the request has completed, the UpdateRequest is still referenced by the connection in the connection pool that executed the request. When the connection processes a new request, the reference is overwritten and only then, the processed request can be garbage collected.&lt;/p&gt;

&lt;p&gt;For large connection pools combined with large parameter objects (e.g. a large document to replace) this leads to significant additional memory use. In our case, this adds an additional gigabyte of memory use, which has noticeable impact on performance.&lt;/p&gt;

&lt;p&gt;It seems that the connection could de-reference any request objects after execution has been completed, as they are no longer needed at that point. That would help reduce the amount of objects that is kept live by the connection pool and would improve overall performance.&lt;/p&gt;</comment>
                            <comment id="1042604" author="peterhendriks" created="Thu, 24 Sep 2015 20:17:31 +0000"  >&lt;p&gt;Example that demonstrates remaining com.mongodb.bulk.UpdateRequest objects.&lt;/p&gt;</comment>
                            <comment id="963304" author="jeff.yemin" created="Fri, 10 Jul 2015 16:30:00 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=peterhendriks&quot; class=&quot;user-hover&quot; rel=&quot;peterhendriks&quot;&gt;peterhendriks&lt;/a&gt; would it be possible to supply a small sample application that demonstrates the problem?&lt;/p&gt;

</comment>
                    </comments>
                    <attachments>
                            <attachment id="91300" name="RemainingUpdateRequestsExample.java" size="2806" author="peterhendriks" created="Thu, 24 Sep 2015 20:17:31 +0000"/>
                    </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|hscr1b:</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="742">Java Sprint 26</customfieldvalue>

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