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

IStateSelection memory leak (BindingFlags.FlattenHierarchy?) #353

Closed
naice opened this issue Nov 2, 2022 · 5 comments
Closed

IStateSelection memory leak (BindingFlags.FlattenHierarchy?) #353

naice opened this issue Nov 2, 2022 · 5 comments
Milestone

Comments

@naice
Copy link

naice commented Nov 2, 2022

Hi,

I've found out that if you not derive directly from FluxorComponent (i have a base component public class LocalizedFluxorComponent : FluxorComponent) a injected IStateSelection creates a memory leak.

I haven't had time yet to dig entirely into the code but I am assuming thats a problem with reflection. But i guess that line

t.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly)

might be the problem. So I was asking myself why won't you use BindingFlags.FlattenHierarchy to get all properties?

@mrpmorris
Copy link
Owner

Ah yes, I see the problem.

I think the correct fix is to remove DeclaredOnly.

If you fancy submitting a PR into https://github.com/mrpmorris/Fluxor/tree/release/5.6 I'll gladly accept it.

@mrpmorris mrpmorris added this to the 5.6 milestone Nov 2, 2022
@naice
Copy link
Author

naice commented Nov 2, 2022

I will do but i am currently unsure if this line really IS the problem. I am gonna check out and investigate.

For the moment I've setup a reproduction project (https://github.com/naice/FluxorMemoryLeak) if you switch between "Counter" and "Fetch data" and observe the console output (Browser) you can see instances stacking... (while clicking on UPDATE COUNT)

Edit: I have changed that method accordingly but that didnt fixed the issue.
Edit2: It also happens if the component is directly derived from FluxorComponent, currently I am not sure if its me thats using Fluxor wrong or if this is a bug, i am also not understanding why this is happening.

@naice
Copy link
Author

naice commented Nov 8, 2022

Have you had time yet to look into my sample?

@mrpmorris
Copy link
Owner

Not yet, sorry

mrpmorris added a commit that referenced this issue Nov 9, 2022
* Ensure StateSelection unsubscribes proprerly - Fixes #353
@mrpmorris
Copy link
Owner

Fixed in 5.6, thank you for letting me know and for creating the repo!

@mrpmorris mrpmorris mentioned this issue Nov 17, 2022
mrpmorris added a commit that referenced this issue Nov 17, 2022
* Ensure StateSelection unsubscribes proprerly - Fixes #353
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants