Skip to content

Conversation

pavelovcharov
Copy link
Contributor

@pavelovcharov pavelovcharov commented Sep 26, 2025

What does the pull request do?

The subscription to the Transform.Changed event was changed from Observable.FromEventPattern to WeakEventHandlerManager.Subscribe (see #19698)

What is the current behavior?

Memory leak observed after LayoutTransformControl is remove from the visual tree.

What is the updated/expected behavior with this PR?

Memory doesn`t leak, LayoutTransformControl is correctly collected

Fixed issues

#19698

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 12.0.999-cibuild0059020-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 12.0.999-cibuild0059022-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 12.0.999-cibuild0059024-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@pavelovcharov pavelovcharov force-pushed the fix/layouttransformcontrol-memory-leak branch from 8e532de to 2399ffc Compare September 27, 2025 21:01
@pavelovcharov pavelovcharov marked this pull request as ready for review September 27, 2025 21:07
@pavelovcharov pavelovcharov marked this pull request as draft September 28, 2025 10:10
@pavelovcharov pavelovcharov force-pushed the fix/layouttransformcontrol-memory-leak branch from 94f2564 to 469724e Compare September 30, 2025 18:11
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 12.0.999-cibuild0059105-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@pavelovcharov pavelovcharov force-pushed the fix/layouttransformcontrol-memory-leak branch from b65ef96 to fe02b0b Compare September 30, 2025 19:01
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 12.0.999-cibuild0059107-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@pavelovcharov pavelovcharov marked this pull request as ready for review September 30, 2025 19:42
@MrJul MrJul added bug backport-candidate-11.3.x Consider this PR for backporting to 11.3 branch labels Oct 1, 2025
@pavelovcharov
Copy link
Contributor Author

@MrJul Please let me know if anything needs to be reworked

Copy link
Member

@MrJul MrJul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! While this PR does fix the leak, it depends on WeakEventManager. That class is using reflection, which we try to avoid.

I think a better solution would be to unsubscribe from the event in OnDetachedFromVisualTree and subscribe to in again in OnAttachedToVisualTree. (Also avoid subscribing at all in LayoutTransformedChanged if the control isn't currently attached to the visual tree).

@pavelovcharov
Copy link
Contributor Author

ОК, will do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-candidate-11.3.x Consider this PR for backporting to 11.3 branch bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants