Browse Source

Fixes

pull/8105/head
Nikita Tsukanov 4 years ago
parent
commit
2d8be0dff6
  1. 7
      src/Avalonia.Base/Rendering/Composition/Transport/BatchStreamArrayPool.cs

7
src/Avalonia.Base/Rendering/Composition/Transport/BatchStreamArrayPool.cs

@ -51,11 +51,12 @@ internal abstract class BatchStreamPoolBase<T> : IDisposable
{ {
var maximumUsage = _usageStatistics.Max(); var maximumUsage = _usageStatistics.Max();
var recentlyUsedPooledSlots = maximumUsage - _usage; var recentlyUsedPooledSlots = maximumUsage - _usage;
while (recentlyUsedPooledSlots < _pool.Count) var keepSlots = Math.Max(recentlyUsedPooledSlots, 10);
while (keepSlots < _pool.Count)
DestroyItem(_pool.Pop()); DestroyItem(_pool.Pop());
_usageStatistics[_usageStatisticsSlot] = 0;
_usageStatisticsSlot = (_usageStatisticsSlot + 1) % _usageStatistics.Length; _usageStatisticsSlot = (_usageStatisticsSlot + 1) % _usageStatistics.Length;
_usageStatistics[_usageStatisticsSlot] = 0;
} }
} }
@ -137,7 +138,7 @@ internal sealed class BatchStreamMemoryPool : BatchStreamPoolBase<IntPtr>
{ {
public int BufferSize { get; } public int BufferSize { get; }
public BatchStreamMemoryPool(int bufferSize = 16384, Action<Func<bool>>? startTimer = null) : base(true, startTimer) public BatchStreamMemoryPool(int bufferSize = 1024, Action<Func<bool>>? startTimer = null) : base(true, startTimer)
{ {
BufferSize = bufferSize; BufferSize = bufferSize;
} }

Loading…
Cancel
Save