react-native-netinfo: Memory leak on iOS

Following up on the closed issue https://github.com/react-native-community/react-native-netinfo/issues/325

This does seem to be an issue with memory leaks, which occur on app start.

Simple reproduction is init a new RN app ad add

React.useEffect(() => {
    const unsubscribe = NetInfo.addEventListener(() => {});
    return () => unsubscribe();
  }, []);

Environment

System:
    OS: macOS 10.15.7
    CPU: (12) x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
    Memory: 1.20 GB / 32.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.16.2 - ~/.nvm/versions/node/v12.16.2/bin/node
    Yarn: 1.22.5 - /usr/local/bin/yarn
    npm: 6.14.4 - ~/.nvm/versions/node/v12.16.2/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /Users/oliverwinter/.rvm/gems/ruby-2.6.1/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.0, DriverKit 19.0, macOS 10.15, tvOS 14.0, watchOS 7.0
    Android SDK: Not Found
  IDEs:
    Android Studio: 4.0 AI-193.6911.18.40.6514223
    Xcode: 12.0.1/12A7300 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_242 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.3 => 0.63.3 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Platforms

Memory leaks were found in iOS on device iPhone 11 pro 14.0.1

Versions

@react-native-community/netinfo”: “5.9.7”,

Description

Screen Shot 2020-10-15 at 1 44 24 pm

Reproducible Demo

add effect in new app and profile on device to see leaks on app start

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 9
  • Comments: 18 (10 by maintainers)

Commits related to this issue

Most upvoted comments

I can confirm issue also exists when using the useNetInfo hook

const connected = useNetInfo();

The beauty of open source is that if there are updates everyone can see them immediately. There’s no secret updates. Anyone that wants to tackle this may feel free @hypothete ? 🙏

Auto release is all set up. Anyone with a PR can have a release almost immediately