flutter-intellij
flutter-intellij copied to clipboard
[perf] Fix incorrect `parentDisposable`s
Using an Application or Project as a parent disposable in plugin code can lead to plugins not being unloaded correctly and with that memory leaks.
See: https://plugins.jetbrains.com/docs/intellij/disposers.html?from=IncorrectParentDisposable#choosing-a-disposable-parent
#8178 gets us nearly there but I'm not sure what to do about AndroidModuleLibraryManager which has a few registrations like this:
https://github.com/flutter/flutter-intellij/blob/0c1007c9ce05c39c284c1b29ef5c203a27cdb7bf/flutter-studio/src/io/flutter/android/AndroidModuleLibraryManager.java#L211
@alexander-doroshko: I wonder if you can advise? Are these Disposer registrations even necessary? If so, how would you migrate them?
@pq Sorry for the delay. I can't answer this specific question right now. This question may disappear as soon as we start working on tech debt and the plugin refactoring.
General answer is that manual Disposer.register is very rarely needed. We try not to use the concept of Disposer/Disposables in new code at all.
So far, I don't fully understand the purpose of the AndroidModuleLibraryManager class. Extending and instantiating ProjectImpl (EmbeddedAndroidProject) looks suspicious by itself.
General answer is that manual Disposer.register is very rarely needed. We try not to use the concept of Disposer/Disposables in new code at all.
I wondered about this and kind of gathered as much.
So far, I don't fully understand the purpose of the AndroidModuleLibraryManager class. Extending and instantiating ProjectImpl (EmbeddedAndroidProject) looks suspicious by itself.
Right. There are lots of internal dependencies in this class and TODOs going that suggest it may not be working as expected. Some dating back to 2018!
It looks like I was a reviewer on this so I'll try and jog my memory. For reference there's https://github.com/flutter/flutter-intellij/pull/2474