Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ios] fix memory leak in Slider #18681

Merged
merged 1 commit into from
Nov 13, 2023
Merged

Conversation

jonathanpeppers
Copy link
Member

Context: #18365

Adding a parameter to the test:

[Theory("Handler Does Not Leak")]
[InlineData(typeof(Slider))]
public async Task HandlerDoesNotLeak(Type type)

Shows a memory leak in Slider, caused by the cycle

  • SliderHandler ->
  • UISlider events ->
  • SliderHandler

I could solve this problem by creating a SliderProxy class -- the same pattern I've used in other PRs to avoid cycles. This makes an intermediate type to handle the events and breaks the cycle.

Still thinking if the analyzer could have caught this, issue filed at:

jonathanpeppers/memory-analyzers#12

Context: dotnet#18365

Adding a parameter to the test:

    [Theory("Handler Does Not Leak")]
    [InlineData(typeof(Slider))]
    public async Task HandlerDoesNotLeak(Type type)

Shows a memory leak in `Slider`, caused by the cycle

* `SliderHandler` ->
* `UISlider` events ->
* `SliderHandler`

I could solve this problem by creating a `SliderProxy` class -- the
same pattern I've used in other PRs to avoid cycles. This makes an
intermediate type to handle the events and breaks the cycle.

Still thinking if the analyzer could have caught this, issue filed at:

jonathanpeppers/memory-analyzers#12
@rmarinho rmarinho merged commit 8d029d4 into dotnet:main Nov 13, 2023
47 checks passed
@jonathanpeppers jonathanpeppers deleted the SliderLeaks branch November 13, 2023 15:03
@github-actions github-actions bot locked and limited conversation to collaborators Dec 14, 2023
@samhouts samhouts added the fixed-in-8.0.6 Look for this fix in 8.0.6 SR1! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fixed-in-8.0.6 Look for this fix in 8.0.6 SR1! memory-leak 💦 Memory usage grows / objects live forever (sub: perf) platform/iOS 🍎
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants