<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:39:12 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>[CSHARP-1297] Memory Leak 2.0 driver</title>
                <link>https://jira.mongodb.org/browse/CSHARP-1297</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;I have a client application that inserts documents into Mongo at a very high speed, using the InsertAsync method. However, the connection pins the objects for too long with AsyncPinned handles, thus increasing my memory usage by a lot until it throws an OutOfMemory exception.&lt;/p&gt;

&lt;p&gt;I solved this partly by implementing object pooling and using BulkWriteAsync, uploading about 5K documents at the same time. This allows the connection to unpin the documents before uploading the next bulk. This works fine for small documents but not for bigger ones. Mongo seems to perform slower with every BulkWrite, steadily increasing my memory again as my pools fill, and eventually throws a Timeout Exception.&lt;/p&gt;

&lt;p&gt;Can this be fixed or is there any other way around it? The performance of this application is very important so I dont want to use the .Wait() option.&lt;/p&gt;</description>
                <environment>Windows</environment>
        <key id="206690">CSHARP-1297</key>
            <summary>Memory Leak 2.0 driver</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</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="shadowsalyer">Fedor Finkenflugel</reporter>
                        <labels>
                            <label>Bug</label>
                            <label>driver</label>
                            <label>question</label>
                    </labels>
                <created>Wed, 27 May 2015 10:30:35 +0000</created>
                <updated>Fri, 5 Apr 2019 13:59:40 +0000</updated>
                            <resolved>Mon, 4 Apr 2016 23:28:34 +0000</resolved>
                                    <version>2.0</version>
                                                    <component>API</component>
                    <component>Performance</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="924511" author="rstam" created="Wed, 27 May 2015 13:16:10 +0000"  >&lt;p&gt;Regarding batching, it is always good for performance to insert documents in batches (though I would recommend you use InsertManyAsync instead of BulkWriteAsync). The reason is that each insert operation is a round trip to the server, so if we can insert multiple documents per round trip performance is better. It doesn&apos;t take very large batches to improve performance significantly. For example, a batch size of 100 potentially eliminates 99 out of 100 round trips (assuming the documents are small enough that 100 of them can fit in a single batch).&lt;/p&gt;

&lt;p&gt;Regarding the out of memory exception, it sounds like you are using fire and forget inserts (I assume that&apos;s what you mean when you say you don&apos;t want to use .Wait). If that&apos;s the case, then you are probably creating fire and forget operations faster than they can be processed. Each operation requires memory, and that memory can&apos;t be freed until the operation completes. If more and more operations are started faster than they can complete the inevitable result is an out of memory exception. In this scenario there is no memory leak per se (the memory would eventually have been released when the operation completes), rather new memory is being allocated faster than old memory is being reclaimed.&lt;/p&gt;

&lt;p&gt;If that hypothesis is correct, you will need to introduce some sort of throttling to keep from creating operations faster than they can be completed. Calling Wait (or using await in async code) is of course the simplest form of throttling. The best way to get the maximum insert performance is to have several Tasks (or threads) doing batched inserts in parallel, but having each Task wait for one operation to complete before starting the next. You may be able to achieve your required performance with a single Task/thread simply by batching the inserts.&lt;/p&gt;

&lt;p&gt;If this explanation doesn&apos;t seem to fit your application please provide additional information and we can dig deeper.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                        <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10011"><![CDATA[Minor Change]]></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_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hs9ptz:</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>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>