Repository: react-native
Issue: FlatList leaks memory when unmounted
Labels: Stale,Component: FlatList,Needs: Triage :mag:

### Description

`FlatList` has a memory leak. When it is unmounted, not all memory is reclaimed.

### Steps to reproduce

Take a look at https://github.com/mmmoussa/rn-perf/pull/1. It makes minor changes to a RN cli bootstrapped app by replacing the rendered setup instructions with a large FlatList containing heavy items. The FlatList mounting can be toggled with a button, with it starting as unmounted. If you mount the FlatList, scroll it, then unmount, you will see that memory usage is significantly higher than when the app was started.

### React Native Version

0.73.2

### Affected Platforms

Runtime - iOS

### Output of `npx react-native info`

```text
System:
  OS: macOS 14.1.2
  CPU: (10) arm64 Apple M1 Pro
  Memory: 240.03 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.10.0
    path: ~/.n/bin/node
  Yarn:
    version: 1.22.19
    path: ~/.yarn/bin/yarn
  npm:
    version: 10.2.3
    path: ~/.n/bin/npm
  Watchman:
    version: 2023.09.04.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.0
      - iOS 17.0
      - macOS 14.0
      - tvOS 17.0
      - watchOS 10.0
  Android SDK:
    API Levels:
      - "28"
      - "30"
      - "31"
      - "32"
      - "33"
      - "34"
    Build Tools:
      - 30.0.2
      - 30.0.3
      - 31.0.0
      - 32.0.0
      - 32.1.0
      - 33.0.0
      - 33.0.0
      - 33.0.1
      - 34.0.0
    System Images:
      - android-26 | Google APIs ARM 64 v8a
      - android-28 | ARM 64 v8a
      - android-28 | Google APIs ARM 64 v8a
      - android-28 | Google ARM64-V8a Play ARM 64 v8a
      - android-29 | Google APIs ARM 64 v8a
      - android-30 | Google APIs ARM 64 v8a
      - android-31 | ARM 64 v8a
      - android-31 | Google APIs ARM 64 v8a
      - android-31 | Google Play ARM 64 v8a
      - android-32 | Google APIs ARM 64 v8a
      - android-32 | Google Play ARM 64 v8a
      - android-33 | Google APIs ARM 64 v8a
      - android-33 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2022.1 AI-221.6008.13.2211.9619390
  Xcode:
    version: 15.0.1/15A507
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.9
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.2
    wanted: 0.73.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false
```


### Stacktrace or Logs

```text
No relevant stacktrace or logs, see the below attached memory usage image.
```


### Reproducer

https://github.com/mmmoussa/rn-perf/pull/1

### Screenshots and Videos

Memory performance in release mode is shown below as recorded from Xcode:
<img width="843" alt="Annotated memory leak graph" src="https://github.com/facebook/react-native/assets/9062287/09856002-7084-49d9-a21e-5c9e651fe10a">