Skip to content

[PERF] migrate Project parentDisposables to Services #8178

New issue

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

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

Already on GitHub? # to your account

Merged
merged 1 commit into from
May 9, 2025

Conversation

pq
Copy link
Contributor

@pq pq commented May 9, 2025

Using a Project as a parent disposable can lead to plugins not being unloaded correctly leading to memory leaks. This follows the advice given in the Jetbrains disposer docs and is (I think) consistent with the Dart plugin (@alexander-doroshko?).

This gets us most of the way to fixing #8107 with an open question about AndroidModuleLibraryManager. (Question posed there 👍 .)


  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

@pq pq requested review from jwren and helin24 May 9, 2025 20:35
Copy link
Member

@helin24 helin24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming you chose analysis server as the parent disposable since it starts early on in plugin startup? Are there times when the analysis server could restart and cause some things to be disposed incorrectly?

@pq
Copy link
Contributor Author

pq commented May 9, 2025

Great question. I chose it because it's a projectService and that seems to be the recommended place to hook in to disposal. I don't think a server restart will have any effect on this as a service but will do a bit more testing.

Thank you!

(EDIT: server restart does not appear to impact the service lifecycle.)

@pq pq merged commit f99f8cc into flutter:master May 9, 2025
7 checks passed
@pq pq deleted the perf_parentDisposables branch May 9, 2025 21:10
@helin24
Copy link
Member

helin24 commented May 9, 2025

Ah yes, that makes sense. Thanks for clarifying my understanding :)

@pq
Copy link
Contributor Author

pq commented May 9, 2025

And thanks for asking! I'm just figuring it out too and definitely don't want to get it wrong!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants