使用插件后内存占用明显升高, 部分页面cpu占用明显升高
LShuXin opened this issue · 2 comments
LShuXin commented
问题: 使用插件后内存占用明显升高, 部分页面cpu占用明显升高
环境:
flutter doctor -v
[✓] Flutter (Channel stable, 3.3.6, on macOS 13.0.1 22A400 darwin-arm, locale zh-Hans-CN)
• Flutter version 3.3.6 on channel stable at /Users/smileflutter/IDE/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 6928314d50 (3 months ago), 2022-10-25 16:34:41 -0400
• Engine revision 3ad69d7be3
• Dart version 2.18.2
• DevTools version 2.15.0
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /Users/smileflutter/Library/Android/sdk
• Platform android-33, build-tools 33.0.0
• ANDROID_HOME = /Users/smileflutter/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14B47b
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
[✓] VS Code (version 1.75.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.0.1 22A400 darwin-arm
• Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.119
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
pubspec.yaml
dependencies:
flutter_boost:
path: 'packages/flutter_boost'
git:
url: 'https://github.com/alibaba/flutter_boost.git'
ref: '4.1.1'
power_image: 0.1.0-pre.2
dependency_overrides:
power_image_ext: 3.0.0
PowerImage相关配置:
imageCache.maximumSize、imageCache.maximumSizeBytes 均使用默认值
class CustomFlutterBinding extends WidgetsFlutterBinding with BoostFlutterBinding {
@override
ImageCache createImageCache() {
return ImageCacheExt();
}
}
// 使用example中的模板
- (void)initPowerImage {
[[PowerImageLoader sharedInstance] registerImageLoader:[PowerImageNetworkImageLoader new] forType:kPowerImageImageTypeNetwork];
[[PowerImageLoader sharedInstance] registerImageLoader:[PowerImageAssetsImageLoader new] forType:kPowerImageImageTypeNativeAsset];
[[PowerImageLoader sharedInstance] registerImageLoader:[PowerImageFlutterAssetImageLoader new] forType:kPowerImageImageTypeAsset];
[[PowerImageLoader sharedInstance] registerImageLoader:[PowerImageFileImageLoader new] forType:kPowerImageImageTypeFile];
}
复现路径:
执行:A页面->B页面->A页面(从B页面pop)
其中A页面是在原生主界面中嵌入的一个Flutter tab,B页面是一个普通的Flutter页面,
项目是一个使用FlutterBoost的混合开发项目,
执行上述操作路径,分别记录使用PowerImage前后的内存占用:
A | B | A |
---|---|---|
292 | 378 | 314 |
291 | 377 | 308 |
A | B | A |
---|---|---|
350 | 455 | 395 |
350 | 460 | 380 |
执行上述操作路径,分别记录使用PowerImage前后的cpu占用:
A | B | A |
---|---|---|
67% | 7% | 65% |
68% | 7% | 65% |
A | B | A |
---|---|---|
66% | 27% | 55% |
60% | 25% | 55% |
LShuXin commented
我自己的问题,我把样例里面的ImageCacheStatusWidget也加上了,造成了很多的重绘
LShuXin commented
不是插件的问题