Skip to content

react-native-performance memory leak patch on Android #72343

@mateuuszzzzz

Description

@mateuuszzzzz

If you haven't already, check out our contributing guidelines and patch guidelines for information on how to manage patches.


Patch Information

Library Name: react-native-performance
Library Version: 5.1.4
Patch Number: 002
Patch Description: fix-listeners-memory-leak
Full Patch Filename: react-native-performance+5.1.4+002+fix-listeners-memory-leak.patch

Patch Details

Reason for Patch

This patch is part of memory leak audit.
react-native-performance has a memory leak where ReactMarker listeners are not properly removed when the module is destroyed. Additionally, setupListener can be called multiple times when getPackages is called multiple times, causing duplicate listeners.

Changes Made

This PR mainly improves how listeners are added and removed. It also extracts lambdas into constants so that they can be consistently referenced when calling addListener and removeListener, preventing duplicate listeners and ensuring that listeners can be properly removed.

Upstream Status

Upstream PR/Issue: oblador/react-native-performance#118

Related Information

PR Introducing Patch: #72341

Additional Notes

This fix isn’t specific to our HybridApp setup, these issues can occur in any bare React Native or brownfield app on Android.

Checklist

  • Patch file is correctly named and placed in the appropriate directory
  • Patch is documented in the corresponding details.md file
  • This issue is linked in the details.md file
  • Upstream PR/issue has been created (if applicable)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions