react / react/react-native

Memory Leak with Fetch

未关闭
#39,100 11 条评论 26 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

🌐Networking Issue: Author Provided Repro Needs: Triage :mag:
主要语言
C++
星标
127k
派生
25.3k
平均合并
1 天 23 小时
30 天内合并 PR
4

描述

Description

I have encountered a memory leak issue when using the fetch function in my React Native application. The memory usage gradually increases over time in iOS, leading to performance degradation and potential crashes.

CleanShot 2023-08-22 at 09 33 37

React Native Version

0.72.4

Output of npx react-native info
  OS: macOS 13.5
  CPU: (10) arm64 Apple M1 Pro
  Memory: 758.45 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.16.0
    path: ~/.nvm/versions/node/v18.16.0/bin/node
  Yarn:
    version: 1.22.19
    path: /opt/homebrew/bin/yarn
  npm:
    version: 9.5.1
    path: ~/.nvm/versions/node/v18.16.0/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.12.1
    path: /Users/clemens/.rvm/gems/ruby-2.7.5/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 22.4
      - iOS 16.4
      - macOS 13.3
      - tvOS 16.4
      - watchOS 9.4
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.3 AI-223.8836.35.2231.10406996
  Xcode:
    version: 14.3.1/14E300c
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.19
    path: /usr/bin/javac
  Ruby:
    version: 2.7.5
    path: /Users/clemens/.rvm/rubies/ruby-2.7.5/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.4
    wanted: 0.72.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false
Steps to reproduce
1.	Create a React Native project with the necessary dependencies.
2.	Implement a screen or component that utilizes the fetch function to make API requests.
3.	Monitor the memory usage of the application over an extended period.
4.	Observe that the memory usage consistently increases during and after making multiple fetch requests.
Snack, screenshot, or link to a repository

minimal example:
https://github.com/clemensmol/rn-fetch-memoryleak

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先,在 iOS 上使用 React Native 0.72.4 运行 https://github.com/clemensmol/rn-fetch-memoryleak 中的最小示例,并监控重复 fetch 请求期间的内存。跟踪请求行为,并比较运行复现程序前后的内存;当已解决所演示的内存增长问题,且复现不再显示内存泄漏时,即视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
ios, javascript, react-native
领域
mobile
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。