Browse Source

Fix ServerCompositionSimplePen memory leak (#19958)

* Fix for Issue#16451

* Remove the pen from the brush observers without queuing the pen for invalidation.
pull/20023/head
aguahombre 3 months ago
committed by GitHub
parent
commit
83b10db596
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 17
      src/Avalonia.Base/Rendering/Composition/Drawing/ServerCompositionSimplePen.cs

17
src/Avalonia.Base/Rendering/Composition/Drawing/ServerCompositionSimplePen.cs

@ -1,12 +1,19 @@
using System;
using Avalonia.Media;
using Avalonia.Media.Immutable;
using Avalonia.Rendering.Composition.Server;
using Avalonia.Rendering.Composition.Transport;
namespace Avalonia.Rendering.Composition.Server;
internal partial class ServerCompositionSimplePen : IPen
{
IDashStyle? IPen.DashStyle => DashStyle;
}
/// <inheritdoc/>
public override void Dispose()
{
// Remove the pen from the brush observers.
// Without this, the pen was being retained in memory by long lived brush resources (e.g. those defined in
// the theme or app resources), hence was causing memory leaks; see Issue #16451
RemoveObserversFromProperty(ref _brush);
_brush = null;
base.Dispose();
}
}

Loading…
Cancel
Save