[CSHARP-160] BsonBuffer pooling improvement Created: 27/Jan/11  Updated: 02/Apr/15  Resolved: 27/Jan/11

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 1.0
Fix Version/s: 1.0

Type: Improvement Priority: Major - P3
Reporter: Aristarkh Zagorodnikov Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The BsonBuffer used in MongoReplyMessage<TDocument> MongoConnectionReceiveMessage<TDocument>(MongoServer) is not disposed, so its chunks aren't released back to the internal chunk pool.
Adding "using (var buffer...)" around the try clause body fixes this.
Also, I believe that MongoReplyMessage.ReadFrom(BsonBuffer) should include similar treatment for the BsonReader (this won't affect anything now, but future development might change this).
I would also recommend to make chunk pool limit, which is currently 64, to be configurable and probably scale with number of processors by default. With heavy traffic



 Comments   
Comment by Robert Stam [ 27/Jan/11 ]

Fixed. Thanks for these very good suggestions.

Comment by Aristarkh Zagorodnikov [ 27/Jan/11 ]

The rationale behind chunk pool limit configuration is that certain applications might use large batch sizes with concurrent access, leading to pool being exhausted very quickly, which in it's turn will cause excessive memory allocations.

Generated at Wed Feb 07 21:35:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.