CSHARP-4669 noted high memory usage when using FLE with GridFS. A forums user noticed the following:
The EncryptField and EncryptFieldAsync methods both call UnwrapValue, which is:
private BsonValue UnwrapValue(byte[] encryptedWrappedBytes) { var rawDocument = new RawBsonDocument(encryptedWrappedBytes); return rawDocument["v"]; }As RawBsonDocument is IDisposable, it should be surrounded by a using clause:
private BsonValue UnwrapValue(byte[] encryptedWrappedBytes) { using var rawDocument = new RawBsonDocument(encryptedWrappedBytes); return rawDocument["v"]; }
We should implement this improvement and verify that it reduces memory usage when using FLE with large documents such as GridFS.
- is related to
-
CSHARP-4669 clientEncryption.Encrypt in C# uses a lot of memory relative to a somewhat large file
- Closed