Skip to content

Massive memory leak when using mobileReplayIntegration #5110

@steelzeh

Description

@steelzeh

What React Native libraries do you use?

Expo (mobile only)

Are you using sentry.io or on-premise?

sentry.io (SaS)

@sentry/react-native SDK Version

6.20.0

How does your development environment look like?

System:
  OS: macOS 14.7.1
  CPU: (10) arm64 Apple M1 Pro
  Memory: 280.23 MB / 16.00 GB
  Shell:
    version: 3.2.57
    path: /bin/sh
Binaries:
  Node:
    version: 22.14.0
    path: /usr/local/bin/node
  Yarn:
    version: 1.22.22
    path: /usr/local/bin/yarn
  npm:
    version: 10.9.2
    path: /usr/local/bin/npm
  Watchman:
    version: 2025.04.14.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods: Not Found
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.1
      - iOS 18.1
      - macOS 15.1
      - tvOS 18.1
      - visionOS 2.1
      - watchOS 11.1
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23339.11.2421.12700392
  Xcode:
    version: 16.1/16B40
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 21.0.4
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 20.0.1
    wanted: latest
  react:
    installed: 19.0.0
    wanted: 19.0.0
  react-native:
    installed: 0.79.6
    wanted: 0.79.6
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Sentry.init()

Sentry.init({
  dsn: "**********",

  sendDefaultPii: true,
  replaysSessionSampleRate: 0.1,
  replaysOnErrorSampleRate: 1,
  integrations: [
    Sentry.mobileReplayIntegration({
      maskAllText: false,
      maskAllImages: false,
      maskAllVectors: false,
    }),
  ],

  // uncomment the line below to enable Spotlight (https://spotlightjs.com)
  // spotlight: __DEV__,
});

Steps to Reproduce

  1. Run yarn create expo-app
  2. Run npx @sentry/wizard@latest -i reactNative
  3. Change the Sentry.init function to include mobileReplayIntegration
  4. Enable the perf monitor
  5. Make a few changes rapidly in the codebase to cause hot-reloads
  6. Observe the RAM spike like crazy

Expected Result

No memory spike

Actual Result

Massive memory spike

sentry-memory-leak.mp4

example-project.zip

Metadata

Metadata

Assignees

No fields configured for issues without a type.

Projects

Status

Waiting for: Community

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions