react-native [BUG] :: MainActivity内存泄漏,当运行前台服务时

bybem2ql  于 4个月前  发布在  React
关注(0)|答案(1)|浏览(110)

描述

当我在运行前台服务时,MainActivity存在内存泄漏问题。

重现步骤

  • 我的应用程序正在运行前台服务,所以当我重复关闭->打开操作大约30次时,会导致内存泄漏。React Native屏幕是否有销毁屏幕的选项?
  • 我保持Android进程运行,但是当我正常关闭(在Android上通过滑动关闭应用程序)并重新打开应用程序时,它会增加应用程序的内存。我们有销毁它的选项吗?

React Native版本

0.73.6

受影响的平台

运行时 - Android

npx react-native info的输出

System:
  OS: macOS 14.5
  CPU: (8) arm64 Apple M1
  Memory: 490.44 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.13.1
    path: ~/.asdf/installs/nodejs/20.13.1/bin/node
  Yarn:
    version: 1.22.22
    path: ~/.asdf/installs/nodejs/20.13.1/bin/yarn
  npm:
    version: 10.5.2
    path: ~/.asdf/plugins/nodejs/shims/npm
  Watchman:
    version: 2024.05.06.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /Users/rom/.asdf/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.3 AI-233.14808.21.2331.11842104
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.11
    path: /Users/rom/.asdf/shims/javac
  Ruby:
    version: 2.7.8
    path: /Users/rom/.asdf/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.6
    wanted: 0.73.6
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

堆栈跟踪或日志

I don't have a stack trace because it is a memory leak

可复现问题

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

截图和视频

Untitled.mp4

fjaof16o

fjaof16o1#

⚠️React Native的新版本可用!
i️您正在使用受支持的次要版本,但似乎有一个更新的补丁可用 - 0.73.8。请升级到您次要版本的最高补丁或最新版本,并验证问题是否仍然存在(或者,创建一个新项目并在其中重现问题)。如果无法重现,请告知我们,以便我们关闭此问题。这有助于确保我们关注仍在最近版本中存在的问题。

相关问题