Skip to content

Commit 73b318a

Browse files
authored
Change default IMemoryStreamFactory (#5740)
* No longer default to RecyclableMemoryStreamFactory * Update comment and release notes
1 parent fe6269c commit 73b318a

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1+
=== MemoryStreamFactory Changes
12

3+
In this release we have changed the value of DefaultMemoryStreamFactory in ConnectionConfiguration such that a new memory stream is used each time. This behavior is more predictable since instances will not be pooled leading to potentially large long-lived allocations. Instead, instances will be created on demand and once release, may be garbage collected.
4+
5+
In advanced situations you may wish to configure the previous default and use the RecyclableMemoryStream.
6+
7+
[source,csharp]
8+
----
9+
var settings = new ConnectionSettings(new Uri("http://localhost:9200"))
10+
.MemoryStreamFactory(RecyclableMemoryStreamFactory.Default);
11+
----

src/Elasticsearch.Net/Configuration/ConnectionConfiguration.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,8 @@ public abstract class ConnectionConfiguration<T> : IConnectionConfigurationValue
173173
private bool _sniffOnStartup;
174174
private bool _throwExceptions;
175175
private bool _transferEncodingChunked;
176-
private IMemoryStreamFactory _memoryStreamFactory = RecyclableMemoryStreamFactory.Default;
176+
private IMemoryStreamFactory _memoryStreamFactory = DefaultMemoryStreamFactory;
177177
private bool _enableTcpStats;
178-
//public static IMemoryStreamFactory Default { get; } = RecyclableMemoryStreamFactory.Default;
179178
public static IMemoryStreamFactory DefaultMemoryStreamFactory { get; } = Elasticsearch.Net.MemoryStreamFactory.Default;
180179
private bool _enableThreadPoolStats;
181180
private bool _enableApiVersioningHeader;
@@ -610,7 +609,7 @@ public T SkipDeserializationForStatusCodes(params int[] statusCodes) =>
610609
public T TransferEncodingChunked(bool transferEncodingChunked = true) => Assign(transferEncodingChunked, (a, v) => a._transferEncodingChunked = v);
611610

612611
/// <summary>
613-
/// The memory stream factory to use, defaults to <see cref="RecyclableMemoryStreamFactory.Default"/>
612+
/// The memory stream factory to use, defaults to <see cref="Elasticsearch.Net.MemoryStreamFactory.Default"/>
614613
/// </summary>
615614
public T MemoryStreamFactory(IMemoryStreamFactory memoryStreamFactory) => Assign(memoryStreamFactory, (a, v) => a._memoryStreamFactory = v);
616615

0 commit comments

Comments
 (0)