-
Notifications
You must be signed in to change notification settings - Fork 25k
Description
Description
Using the new architecture images loaded from a ph:// cause major memory leaks. Unlike images loaded via assets or a remote uri, images loads via ph:// uris seem to be loaded in to memory, but then not released when the image component is unmounted. This is not an issue on the old architecture.
I've tested on a real device and experience the same behaviour. I've also tested in Release to ensure it's not a dev/debug issue.
I have attached a video of the issue below, plus a video of the same app running with the new arch disabled which shows no memory leaks.
Steps to reproduce
- Pull repo: https://github.com/alexfoxy/ImageMemoryTest
- Follow usual RN setup, yarn, pod etc and run the project
- Press "Use PH Image" button to load an image from your camera roll (it should be a high resolution image if possible)
- Show & Hide the image using the buttons, you should notice memory increasing
- Try the Asset Image & Remote Image for comparison which do not increase memory
React Native Version
0.79.2
Affected Platforms
Runtime - iOS
Output of npx @react-native-community/cli info
System:
OS: macOS 15.1.1
CPU: (10) arm64 Apple M2 Pro
Memory: 208.94 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 22.13.0
path: ~/.nvm/versions/node/v22.13.0/bin/node
Yarn:
version: 4.7.0
path: ~/.nvm/versions/node/v22.13.0/bin/yarn
npm:
version: 10.9.2
path: ~/.nvm/versions/node/v22.13.0/bin/npm
Watchman:
version: 2025.04.14.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.16.2
path: /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.2
- iOS 18.2
- macOS 15.2
- tvOS 18.2
- visionOS 2.2
- watchOS 11.2
Android SDK: Not Found
IDEs:
Android Studio: 2024.1 AI-241.19072.14.2412.12360217
Xcode:
version: 16.2/16C5032a
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.9
path: /usr/bin/javac
Ruby:
version: 3.4.3
path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
"@react-native-community/cli":
installed: 18.0.0
wanted: 18.0.0
react:
installed: 19.0.0
wanted: 19.0.0
react-native:
installed: 0.79.2
wanted: 0.79.2
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: true
Stacktrace or Logs
No stack trace or log
MANDATORY Reproducer
https://github.com/alexfoxy/ImageMemoryTest
Screenshots and Videos
I had to upload the videos to YouTube as they wouldn't attach here:
New Arch: https://www.youtube.com/watch?v=6U9QtshkRCs
Old Arch: https://www.youtube.com/watch?v=1C2xZEKFB24