Skip to content

[ios] fix memory leak in Slider#18681

Merged
rmarinho merged 1 commit intodotnet:mainfrom
jonathanpeppers:SliderLeaks
Nov 13, 2023
Merged

[ios] fix memory leak in Slider#18681
rmarinho merged 1 commit intodotnet:mainfrom
jonathanpeppers:SliderLeaks

Conversation

@jonathanpeppers
Copy link
Copy Markdown
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
@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! perf/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