<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:51:42 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-191]  Possible leak in Java 2.2 Driver with ReplicaSetStatus$Updater </title>
                <link>https://jira.mongodb.org/browse/JAVA-191</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;There appears to be a leak in the latest Mongo&lt;br/&gt;
Driver. It would be most pronounced in a web app where you&apos;d have&lt;br/&gt;
multiple instances of Mongo being created, perhaps even created over&lt;br/&gt;
and over during development as an application is reinitialized but the&lt;br/&gt;
server (i.e. the VM) itself isn&apos;t actually restarted.  I&apos;m doing this&lt;br/&gt;
within the context of ColdFusion, but this would be true of any&lt;br/&gt;
container-based java app.&lt;/p&gt;

&lt;p&gt;To replicate, you should just need to create multiple instances of&lt;br/&gt;
Mongo (with ServerAddresses constructor) and let them go out of scope&lt;br/&gt;
as they normally would... maybe it&apos;s a singleton object that&lt;br/&gt;
reinitializes its internal Mongo instance or something.&lt;/p&gt;

&lt;p&gt;What I&apos;m seeing is that those Mongo instances stay around forever. If&lt;br/&gt;
I&apos;m reading the output of Eclipse&apos;s Memory Analyzer correctly, it&apos;s&lt;br/&gt;
due to ReplicaSetStatus$Updater.&lt;/p&gt;

&lt;p&gt;I haven&apos;t read the source, but it appears that this spawns a thread&lt;br/&gt;
that presumably checks for replica set members&apos; status. However,&lt;br/&gt;
that&apos;s keeping these objects alive even after the request that spawned&lt;br/&gt;
them ends.&lt;/p&gt;


&lt;p&gt;In the forums, Eliot suggested calling Mongo.close(). I did that and observed two things:&lt;/p&gt;

&lt;p&gt;1) After doing so and taking a heap dump, the ReplicaSetStatus$Updater instances still remained. This was also evidenced by shutting down Mongo and watching the com.mongodb.ReplicaSetStatus$Node update Warning errors still appear in the app server logs&lt;/p&gt;

&lt;p&gt;2) when initializing Mongo with a server/port and not a List of ServerAddresses, calling Mongo.close() throws an error. This is in the context of my web container. I could not replicate it in a simple standalone java example.  &lt;/p&gt;

&lt;p&gt;java.lang.NullPointerException at&lt;br/&gt;
com.mongodb.DBTCPConnector.close(DBTCPConnector.java:352)&lt;br/&gt;
at com.mongodb.Mongo.close(Mongo.java:297)&lt;br/&gt;
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)&lt;br/&gt;
at&lt;br/&gt;
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:&lt;br/&gt;
39)&lt;br/&gt;
 at&lt;br/&gt;
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:&lt;br/&gt;
25)&lt;br/&gt;
at java.lang.reflect.Method.invoke(Method.java:597)&lt;br/&gt;
at coldfusion.runtime.java.JavaProxy.invoke &lt;/p&gt;</description>
                <environment></environment>
        <key id="13387">JAVA-191</key>
            <summary> Possible leak in Java 2.2 Driver with ReplicaSetStatus$Updater </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="eliot">Eliot Horowitz</assignee>
                                    <reporter username="marcesher">Marc Esher</reporter>
                        <labels>
                    </labels>
                <created>Fri, 15 Oct 2010 12:08:00 +0000</created>
                <updated>Fri, 29 Oct 2010 02:48:53 +0000</updated>
                            <resolved>Wed, 27 Oct 2010 20:28:10 +0000</resolved>
                                    <version>2.2</version>
                                    <fixVersion>2.3</fixVersion>
                                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="19724" author="auto" created="Wed, 27 Oct 2010 20:28:19 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;login&apos;: &apos;erh&apos;, &apos;name&apos;: &apos;Eliot Horowitz&apos;, &apos;email&apos;: &apos;eliot@10gen.com&apos;}
&lt;p&gt;Message: fix potential memory leak &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-191&quot; title=&quot; Possible leak in Java 2.2 Driver with ReplicaSetStatus$Updater &quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-191&quot;&gt;&lt;del&gt;JAVA-191&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://github.com/mongodb/mongo-java-driver/commit/d55d9919cc2cc90a69d97091a816eb0b195b762f&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://github.com/mongodb/mongo-java-driver/commit/d55d9919cc2cc90a69d97091a816eb0b195b762f&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|hrhcqf:</customfieldvalue>

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