When using navigagtion.push() in a stack navigator, RAM usage increases indefinitely, then stays high even after hot reloading metro bundler.
This is a similar issue to this one, but I'm making a new issue because I'm specifically worried about the fact that the RAM usage does not go back down after hot reloading the app.
Here is a video of the behavior.
The app is just a single home page in a stack navigator that contains a flatlist of 100 images, and a button to push the same home page onto the stack. RAM usage starts out at ~130 MB, goes up to ~300 MB after pushing the page 20-30 times, then after hot reloading stays at around ~250 MB. Snack with the exact code shown here provided below.
What is the reason that RAM usage does not reset after reloading? Am I missing some kind of memory management that I should be doing?
Snack with code to reproduce:
https://snack.expo.dev/@spagrhetti/react-navigation-stack-increasing-ram
Expected behavior:
I would expect that even if RAM usage increases from ~130 MB to ~300 MB, it would go back down to ~130 MB after hot reloading metro bundler.
Link to issue I made:
https://github.com/react-navigation/react-navigation/issues/11762