Browse Source

Fixed bitmaps not getting disposed correctly causing a memory leak in RemoteWidget

pull/3728/head
Marcus Wichelmann 7 years ago
parent
commit
92770765e3
  1. 6
      src/Avalonia.Controls/Remote/RemoteWidget.cs

6
src/Avalonia.Controls/Remote/RemoteWidget.cs

@ -75,7 +75,11 @@ namespace Avalonia.Controls.Remote
var fmt = (PixelFormat) _lastFrame.Format; var fmt = (PixelFormat) _lastFrame.Format;
if (_bitmap == null || _bitmap.PixelSize.Width != _lastFrame.Width || if (_bitmap == null || _bitmap.PixelSize.Width != _lastFrame.Width ||
_bitmap.PixelSize.Height != _lastFrame.Height) _bitmap.PixelSize.Height != _lastFrame.Height)
_bitmap = new WriteableBitmap(new PixelSize(_lastFrame.Width, _lastFrame.Height), new Vector(96, 96), fmt); {
_bitmap?.Dispose();
_bitmap = new WriteableBitmap(new PixelSize(_lastFrame.Width, _lastFrame.Height),
new Vector(96, 96), fmt);
}
using (var l = _bitmap.Lock()) using (var l = _bitmap.Lock())
{ {
var lineLen = (fmt == PixelFormat.Rgb565 ? 2 : 4) * _lastFrame.Width; var lineLen = (fmt == PixelFormat.Rgb565 ? 2 : 4) * _lastFrame.Width;

Loading…
Cancel
Save