MixinNetwork / MixinNetwork/flutter-plugins
A lot of Ram Memory Usage and not decrease even the webview close on Flutter Desktop App (Windows/Linux)
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 512
- Forks
- 292
- Avg merge
- 15h 8m
- Merged PRs (30d)
- 7
Description
Every time I open the window, the memory increases by about 100 to 150 MB, and the memory is not released when the window is closed.
Basically, In my app, I have a playlist of web views in which I have 5 web views and every web view opens for 10 seconds and then closes and the next opens, and so on and it runs continuously. For example, when the first web view opened the RAM was like 200MB, and when it closed and the next web view opened the memory exceeded 300 or more, and the same increased after every web view.
This is my code to open the web view, I'm doing this in the InitState of my widget, and I'm closing this controller in dispose method
if (PlatformUtils.isDesktop) {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
final Size screenSize = MediaQuery.of(context).size;
setState(() {
screenWidth = screenSize.width;
screenHeight = screenSize.height;
});
if(widget.showBlank == true) {
if (screenWidth != null && screenHeight != null) {
var webView = await LinuxWebView.WebviewWindow.create(
configuration: LinuxWebView.CreateConfiguration(
titleBarHeight: 0,
titleBarTopPadding: 0,
windowHeight: screenHeight!.toInt(),
windowWidth: screenWidth!.toInt(),
openMaximized: true
),
);
webViewLinux = webView;
webViewLinux?.launch(widget.url);
setState(() {
});
}
}else{
setState(() {
ShowBlankScreen(gotoMenuScreen: widget.gotoMenuScreen,);
});
}
});
}
@override
void dispose() async{
super.dispose();
AppLogger.logInfo('Webview disposed');
print('Webview disposing...');
await webViewLinux?.stop();
webViewLinux?.onClose;
webViewLinux?.close();
print('Webview disposed');
screenOnOfObserverListener.cancel();
}
}
Please tell me how to handle memory usage for this scenario
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with LinuxWebView.WebviewWindow.create and the stop(), close(), and dispose() lifecycle calls shown in the report. Reproduce the five-webview playlist on Flutter desktop for Windows or Linux, then trace whether each closed webview releases its resources; done means repeated open-and-close cycles no longer show unbounded memory growth.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- desktop-dev, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100