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

Finalizable objects require multiple garbage collection to clean up and may cause performance issues #378

Closed
sallyjwhite opened this issue Dec 6, 2022 · 2 comments · Fixed by #381

Comments

@sallyjwhite
Copy link

We have a production version of Blazor Server running on Azure, that extensively uses Fluxor. We were investigating a memory leak and have found that the application is holding on to Flxuor Subscriptions preventing the subscription from being removed through the GC.
Screenshot shows 15K Fluxor.DisposableCallbacks in the "Finalizable objects require multiple garbage collection to clean up and may cause performance issues" memory analysis report on Azure after 15 hours of up time and a maximum of 40 users.
image

We did some digging and found that if we tweaked the UnsubscribeFromAllActions in ActionSubscriber.cs class to include:

            IEnumerable<object> subscribedInstances =
                instanceSubscriptions
                    .Select(x => x.Subscriber)
                    .Distinct();
            foreach (object subscription in subscribedInstances)
            {
                if (SubscriptionsForInstance.ContainsKey(subscription))
                    SubscriptionsForInstance.Remove(subscription);
            }

The Fluxor.DisposableCallbacks dropped to around 700

Complete Class:
ActionSubscriber.txt

Would you consider adding this to your codebase?

@mrpmorris
Copy link
Owner

Hiya

Could you fork the repo and submit a PR to branch release/5.7, please?

I'll check the diff, and then we can discuss what is happening.

Thanks!

mrpmorris added a commit that referenced this issue Dec 9, 2022
#378) (#380)

Fix memory leak when using ActionSubscriber or SubscribeToAction (Fixes #378)
@mrpmorris mrpmorris mentioned this issue Dec 9, 2022
mrpmorris added a commit that referenced this issue Dec 9, 2022
#378) (#380)

Fix memory leak when using ActionSubscriber or SubscribeToAction (Fixes #378)
@mrpmorris
Copy link
Owner

Released in 5.7

mrpmorris added a commit that referenced this issue May 18, 2023
* Fix memory leak when using ActionSubscriber or SubscribeToAction (Fixes #378) (#380)

Fix memory leak when using ActionSubscriber or SubscribeToAction (Fixes #378)

* fix minor typo in docs (#398)

typo found in State, Actions, and Reducers

* Fixe typo

* Argument order fix (#416)

Fixed order of arguments in `ReduceFetchDataResultAction()`

---------

Co-authored-by: Adam Hewitt <[email protected]>
Co-authored-by: Steven T. Cramer <[email protected]>
Co-authored-by: Phil Watson <[email protected]>
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

Successfully merging a pull request may close this issue.

2 participants