High memory usage for `Text` component on iOS
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- C++
- Estrellas
- 127k
- Forks
- 25.3k
- Merge medio
- 1 d 23 h
- PR fusionados (30 d)
- 4
Descripción
Description
When working on memory optimisation of a complex RN app, I found that Text components on iOS can consume relatively large amounts of memory. When I've checked that with Xcode Instruments, it seems that each RCTParagraphTextView is accompanied by a backing CALayer which consumes memory proportional to its rendered size, more precisely width x height x 4 bytes (RGBA channels).
While individual Text instances are small, complex UI, esp. using stacked screens & virtualized lists can add up to quite large number (tens of MB), especially if the app uses large font sizes in such lists.
For example, each of the following Text components consumes about 112-140 KB of memory, due to the backing raster.
This can be observed using Allocations Xcode Instrument by marking memory before and after adding text views.
I've created a small app for easily measuring various components' memory usage: https://github.com/mdjastrzebski/rn-memory-footprint
Note:
- on Android, this issue does not seem to happen, as all Text have similar size, regardless of used font size
- on iOS, when using native
UILabel, these are much smaller, and do not haveCALayersattached
Steps to reproduce
- Download the reproducer app
yarn install&yarn ios:releaseORyarn android:release- Run the app on a simulator or a device
- Attach Allocation Xcode Instrument, mark generation A
- Pick "Text (Large Font)" from the component dropdown
- Press "Create Views"
- Wait a couple of seconds, mark generation B in instruments
- Compare memory usage. You should see a lot of
RCTParagraphTextView (CALayer)entries, each taking 120-140 KBs.
React Native Version
0.82.1
Affected Platforms
Runtime - iOS
Output of npx @react-native-community/cli info
System:
OS: macOS 26.1
CPU: (11) arm64 Apple M3 Pro
Memory: 102.75 MB / 36.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 22.17.1
path: /Users/mdj/.nvm/versions/node/v22.17.1/bin/node
Yarn:
version: 4.12.0
path: /Users/mdj/.nvm/versions/node/v22.17.1/bin/yarn
npm:
version: 10.9.2
path: /Users/mdj/.nvm/versions/node/v22.17.1/bin/npm
Watchman:
version: 2025.07.28.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.16.2
path: /Users/mdj/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 25.0
- iOS 26.0
- macOS 26.0
- tvOS 26.0
- visionOS 26.0
- watchOS 26.0
Android SDK:
API Levels:
- "35"
- "36"
Build Tools:
- 35.0.0
- 36.0.0
System Images:
- android-35 | Google Play ARM 64 v8a
- android-36 | Google Play ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2025.2 AI-252.25557.131.2521.14432022
Xcode:
version: 26.0.1/17A400
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.16
path: /usr/bin/javac
Ruby:
version: 3.4.5
path: /Users/mdj/.rbenv/shims/ruby
npmPackages:
"@react-native-community/cli":
installed: 20.0.0
wanted: 20.0.0
react:
installed: 19.1.1
wanted: 19.1.1
react-native:
installed: 0.82.1
wanted: 0.82.1
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: true
Stacktrace or Logs
n/a
MANDATORY Reproducer
https://github.com/mdjastrzebski/rn-memory-footprint
Screenshots and Videos
Added above
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Reproduce el problema con la aplicación rn-memory-footprint enlazada usando el componente “Text (Large Font)” y Xcode Allocations Instrument. Empieza trazando RCTParagraphTextView y su CALayer subyacente; después, compara el comportamiento observado en iOS con UILabel nativo y Android; se considera terminado cuando se haya solucionado el uso excesivo de memoria por vista sin cambiar el comportamiento de Text.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- ios, react-native
- Área
- mobile, performance
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100