software-mansion / software-mansion/react-native-screens

[Android] :: running foreground cause screen fragment memory leak

Open
#2,179 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

platform:android repro-provided
Dominant language
TypeScript
Stars
3.7k
Forks
714
Avg merge
2d 23h
Merged PRs (30d)
71

Description

Description

I have an issue with the app memory leak, I have read the old issue https://github.com/software-mansion/react-native-screens/issues/843#issuecomment-832034119

  • my app is running foreground service so when I repeat it about 30 times close -> open -> it causes a memory leak does the react native screen have an option to destroy the screen?
  • I keep the Android process running but when I close (swipe the app out normally in Android swipe the app out it would be killed) and open the app it increases the app memory do we have the option to destroy it?
  • is there any better solution for this case ?

Screenshot 2024-06-11 at 09 26 25

Steps to reproduce
  • running foreground service and keeping the app processes alive
  • open -> close -> repeat 10times

https://github.com/software-mansion/react-native-screens/assets/65760336/05f48f62-0394-43f1-8286-e2146c1b9822

Snack or a link to a repository

https://github.com/chanphiromsok/rnn-screen-leak

Screens version

3.30.1

React Native version

0.74.2 and 0.73

Platforms

Android

JavaScript runtime

Hermes Engine

Workflow

Expo managed workflow

Architecture

Paper (Old Architecture)

Build type

Release mode

Device

Real device

Device model

Samsung Galaxy S10 + any Android devices

Acknowledgements

Yes

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked reproduction repository and reproduce the leak on Android by repeatedly opening and closing the app while the foreground service keeps the process alive. Trace the react-native-screens lifecycle during those transitions and compare memory behavior with the reported versions; done requires a confirmed cause and an actionable fix or documented limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, react-native, typescript
Domain
mobile, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.