<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:53:10 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-831] Memory leak </title>
                <link>https://jira.mongodb.org/browse/JAVA-831</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;If authentication fails monglo cleaner thread will stuck in waiting state forever. So if you try continuously to connect to the database it causes the memory leak. I tried to look at javadoc and there is no information that it is necessary to call close() if authentication fails. And tutorial for beginner is withou calling method close() if authentication fails &lt;a href=&quot;http://docs.mongodb.org/ecosystem/tutorial/getting-started-with-java-driver/#getting-started-with-java-driver&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://docs.mongodb.org/ecosystem/tutorial/getting-started-with-java-driver/#getting-started-with-java-driver&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is my stackt trace&lt;br/&gt;
com.mongodb.MongoException$Network: IOException authenticating the connection&lt;br/&gt;
at com.mongodb.DBPort$NativeAuthenticator.authenticate(DBPort.java:552)&lt;br/&gt;
	at com.mongodb.DBPort.authenticate(DBPort.java:322)&lt;br/&gt;
	at com.mongodb.DBTCPConnector.authenticate(DBTCPConnector.java:621)&lt;br/&gt;
	at com.mongodb.DBApiLayer.doAuthenticate(DBApiLayer.java:180)&lt;br/&gt;
	at com.mongodb.DB.authenticateCommandHelper(DB.java:630)&lt;br/&gt;
	at com.mongodb.DB.authenticate(DB.java:588)&lt;/p&gt;


&lt;p&gt;I think that it should be fixed in connector in method authenticate so I send pull request for it.&lt;/p&gt;

&lt;p&gt;If it is fixed in wrong place or in wrong way, please correct it. If it should not be fixed please update mongo java driver tutorial and javadoc to prevent that another beginner create memory leak in his application.&lt;/p&gt;

&lt;p&gt;Thanks a lot&lt;/p&gt;</description>
                <environment></environment>
        <key id="75908">JAVA-831</key>
            <summary>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="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="-1">Unassigned</assignee>
                                    <reporter username="lvotypko">lucie votypkova</reporter>
                        <labels>
                    </labels>
                <created>Mon, 20 May 2013 15:25:57 +0000</created>
                <updated>Wed, 19 Oct 2016 14:17:29 +0000</updated>
                            <resolved>Thu, 23 May 2013 16:16:43 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="346874" author="vjuranek" created="Tue, 28 May 2013 14:43:46 +0000"  >&lt;p&gt;If I don&apos;t close Sockets, AFAIK I don&apos;t run into OOM. If, for any reason, close() is not call (somethign unexpected happens, you undeploy the app without calling it - see e.g. &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-817&quot; title=&quot;PermGen memory leak. A deamon thread &amp;quot;CursorCleanerThread&amp;quot;  doesn&amp;#39;t stopped when undeploy a web application.&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-817&quot;&gt;&lt;del&gt;JAVA-817&lt;/del&gt;&lt;/a&gt;), Mongo objects will be kept in memory forever. I&apos;m not saying it&apos;s unreasonable design, but rather unexpected as I would expect that these objects are removed by GC later on. If not, in such case I would expect Mongo to be a singleton so that there is only one instance.&lt;/p&gt;</comment>
                            <comment id="346806" author="jeff.yemin" created="Tue, 28 May 2013 13:18:27 +0000"  >&lt;p&gt;You just need to call close() the Mongo instance.  I don&apos;t think this is an unreasonable design choice.  It&apos;s no different in principle than having to call close() on a Socket, for instance. &lt;/p&gt;</comment>
                            <comment id="346122" author="vjuranek" created="Mon, 27 May 2013 08:29:29 +0000"  >&lt;p&gt;Hi,&lt;br/&gt;
authenticate is not the only case, basically it can happen elsewhere and CursorCleanerThread will be kept in JVM (together with Mongo object), until JVM finishes. IMHO this is not a comfortable design. Do you consider e.g. moving CursorCleanerThread into separate class and reference Mongo object by a weak reference (with checking, if referenced mongo instance is not null in CursorCleanerThread#run - if it&apos;s null, it was GCed and thread can finish)?&lt;br/&gt;
Thanks&lt;/p&gt;</comment>
                            <comment id="343803" author="trisha.gee@10gen.com" created="Thu, 23 May 2013 16:13:49 +0000"  >&lt;p&gt;Thanks for the pull request, but this is not really the correct behaviour - &quot;authenticate&quot; in DBTCPConnector should not be responsible for closing anything, this would be unexpected to the user.&lt;/p&gt;

&lt;p&gt;It&apos;s really down to the calling code to ensure that the authenticate method passed, and deal with failures in a way that is appropriate to the application or business, your application should know how to handle authentication failures.&lt;/p&gt;</comment>
                            <comment id="339824" author="lvotypko" created="Mon, 20 May 2013 15:29:43 +0000"  >&lt;p&gt;here is my pull request &lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/pull/117&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/pull/117&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                    <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|hrnz2f:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>53648</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>