react-native: Memory Leak in 0.16
Looks like the base React-Native app has a memory leak
Running react-native init AwesomeProject
and then running the app produces the following memory graph.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 3
- Comments: 48 (18 by maintainers)
@battman21 I think everyone is baffled. Even the cause was identified three months ago but still is yet to be resolved.
@jeremyong If the leak is causing your app to be “unrunnable” after a few minutes of use, then yes, of course I consider it a blocking issue.
When I commented previously, that wasn’t my understanding of the problem (and I’m sorry if I misunderstood). It seemed as though it was something that happened over long term use, or at least at a slow rate…specifically, a rate that wasn’t detrimental to the dev process. There are many things to work on in RN, and I was merely trying to triage, not dismiss completely.
Regarding debugging an actual leak…in typical React/React Native development, you wouldn’t debug leaks in dev mode…there are specifically dev helpers (logging, error messages etc) that use resources that wouldn’t be used in production. You would debug that leak in production mode…as close to the environment that the app will finally live in as possible.
RE: the cause of the leak – honestly, I had missed the comment on this issue 21 days ago that alluded to it. Let me review the associated PR’s in the morning, and see 1) whether we can take immediate action or 2) if we can do a bit more work to come to a solution. It’s not intentional that I (or we) was ignoring this issue…just a consequence of being mentioned and subscribed to many issues on this repo, and it’s hard to keep up. Thanks for mentioning me and bringing it up again.
Also, @sebmarkbage has mentioned recently that he and others on the React team want to audit “dev mode” in React, to make sure that it’s not doing things that it doesn’t need to do and that (possibly) don’t cause issues such as memory leaks. I’ll let him speak to it here.
@skevy
I’m not sure what aspect of a memory leak that causes my app to be unrunnable after a few minutes of use in a simulator makes dev mode easier to debug.
Also how are you supposed to debug an actual leak if leaks already exist? The reason debug builds are slow is because unoptimized code maps in a one to one fashion to source code, which makes it easy to step through a debugger. That’s it. The presence of leaks and other bugs in debug mode should be just as serious as bugs in any other mode. I think this is a pretty fundamental software engineering discipline.