-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 2.7.3
-
Component/s: Performance, Serialization
-
None
The profiler output of a session that involved serialization of more than 2 million complex documents shows the following result - 36GB of memory allocated only by the BsonWriter.WriteName method:
The culprit for that appears to be the lambda expression here: https://github.com/mongodb/mongo-csharp-driver/blob/dc2dbb5ff06fdea80b44a8c2295e542f166ccb16/src/MongoDB.Bson/IO/BsonWriter.cs#L279
_childElementNameValidatorFactory = () => _elementNameValidator.GetValidatorForChildContent(name);
It would certainly be beneficial to move to an alternative design that does not result in closures.
- is duplicated by
-
CSHARP-1942 Reducing delegate allocations
- Closed