Repository: flutter
Issue: [ios]When loading HEIC pictures, the memory will suddenly increase, and then crash
Labels: c: crash,platform-ios,engine,c: performance,a: images,perf: memory,has reproducible steps,P2,found in release: 3.10,found in release: 3.12,team-ios,triaged-ios

## Details

**Target Platform:** iOS
**Target OS version/browser:** iOS 16.5
**Devices:** iPhone 12 pro max

My app will display a lot of photos taken from the device, and I found that many times when loading photos in heic format, the memory will suddenly increase, then drop, and sometimes it will even crash due to memory problems. The following example is just a simple picture list (about 1700 pictures). When you slide down, the memory will explode. In addition, using photos in jpeg format, the memory usage will be much lower.

crash log
```shell
* thread #18, name = 'io.worker.6', stop reason = EXC_RESOURCE (RESOURCE_TYPE_MEMORY: high watermark memory limit exceeded) (limit=3072 MB)
    frame #0: 0x0000000202e560a8 libsystem_platform.dylib`_platform_memmove + 88
libsystem_platform.dylib`:
->  0x202e560a8 <+88>:  stnp   q0, q1, [x3]
    0x202e560ac <+92>:  add    x3, x3, #0x20
    0x202e560b0 <+96>:  ldnp   q0, q1, [x1]
    0x202e560b4 <+100>: add    x1, x1, #0x20
Target 0: (Runner) stopped.
```
sample code
```dart
class PagePhotoList extends StatefulWidget {
  const PagePhotoList({Key? key}) : super(key: key);

  @override
  State<StatefulWidget> createState() => _PagePhotoListState();
}

class _PagePhotoListState extends State<PagePhotoList> {
  // a photo path list that i load from device, about 1700 image in in heic format
  var _photoList = <String>[];

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      itemBuilder: _imageItemBuilder,
      itemCount: _photoList.length,
      itemExtent: 279.w,
      cacheExtent: 500,
    );
  }

  Widget _imageItemBuilder(BuildContext context, int index) {
    return SizedBox(
      width: 355.w,
      height: 279.w,
      child: Image.file(
        File(_photoList[index]),
        width: 355,
        height: 279,
        cacheHeight: 355 * MediaQuery.of(context).devicePixelRatio.toInt(),
      ),
    );
  }
}
```
<img width="1506" alt="devtool3" src="https://github.com/flutter/flutter/assets/32166473/60ecb56f-7ff6-4c14-a5ff-7e11b9b5c8d0">
<img width="774" alt="devtool4" src="https://github.com/flutter/flutter/assets/32166473/3de5bdcf-1238-4df5-b4c7-62ed5accdaf5">

flutter doctor -v
```shell
[✓] Flutter (Channel stable, 3.7.12, on macOS 13.3 22E252 darwin-arm64, locale
    zh-Hans-CN)
    • Flutter version 3.7.12 on channel stable at /Users/mac/Flutter/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • FLUTTER_GIT_URL = https://github.com/flutter/flutter.git
    • Framework revision 4d9e56e694 (8 weeks ago), 2023-04-17 21:47:46 -0400
    • Engine revision 1a65d409c7
    • Dart version 2.19.6
    • DevTools version 2.20.1
    • 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 30.0.3)
    • Android SDK at /Users/mac/Library/Android/sdk
    • Platform android-33, build-tools 30.0.3
    • Java binary at: /Users/mac/Library/Application
      Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.1012163
      9/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E222b
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • Android Studio at /Users/mac/Library/Application
      Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.1012163
      9/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
      17.0.6+0-17.0.6b802.4-9586694)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.1.2)
    • IntelliJ at /Users/mac/Applications/JetBrains Toolbox/IntelliJ IDEA
      Ultimate.app
    • Flutter plugin version 73.1.1
    • Dart plugin version 231.9065

[✓] IntelliJ IDEA Ultimate Edition (version 2023.1.2)
    • IntelliJ at /Users/mac/Library/Application
      Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.9011.34/IntelliJ IDEA.app
    • 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

[✓] Connected device (3 available)
    • Oneup的iPhone (mobile) • 00008101-001574D23EE1001E • ios            • iOS
      16.5 20F66
    • macOS (desktop)       • macos                     • darwin-arm64   • macOS
      13.3 22E252 darwin-arm64
    • Chrome (web)          • chrome                    • web-javascript •
      Google Chrome 114.0.5735.106

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
```