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 Stepper #18663

Merged
merged 1 commit into from
Nov 10, 2023
Merged

Conversation

jonathanpeppers
Copy link
Member

Context: #18365

Adding a parameter to the test:

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

Shows a memory leak in Stepper, caused by the cycle

  • StepperHandler ->
  • UIStepper.ValueChanged event ->
  • StepperHandler

I could solve this problem by creating a StepperProxy 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(Stepper))]
    public async Task HandlerDoesNotLeak(Type type)

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

* `StepperHandler` ->
* `UIStepper.ValueChanged` event ->
* `StepperHandler`

I could solve this problem by creating a `StepperProxy` 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
@jonathanpeppers jonathanpeppers added platform/iOS 🍎 memory-leak 💦 Memory usage grows / objects live forever labels Nov 9, 2023
@jonathanpeppers jonathanpeppers added this to the .NET 8 + Servicing milestone Nov 9, 2023
@ghost ghost added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Nov 10, 2023
@jonathanpeppers jonathanpeppers marked this pull request as ready for review November 10, 2023 04:41
@jonathanpeppers jonathanpeppers requested a review from a team as a code owner November 10, 2023 04:41
@rmarinho rmarinho merged commit 71b591c into dotnet:main Nov 10, 2023
47 checks passed
@jonathanpeppers jonathanpeppers deleted the StepperLeaks branch November 10, 2023 13:39
@github-actions github-actions bot locked and limited conversation to collaborators Dec 11, 2023
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
@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
area-controls-stepper Stepper fixed-in-8.0.6 Look for this fix in 8.0.6 SR1! memory-leak 💦 Memory usage grows / objects live forever platform/iOS 🍎
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants