Description

      After upgrading to 10.20.0-beta.3 I've been receiving some crashes related to memory warnings and eventual app termination.

      I've been trying to debug the issue, and there's really no obvious culprit. However, there seems to be a very slow memory leak when listening to collections and/or querying/updating data for long periods of time.

      I'm also not able to get the exact location of the memory leak, as XCode is not giving me that information, which also hints at some low level C allocation.

      The following capture shows the app doing nothing besides the reproduction steps highlighted below. Basically, have a collection listener, and perform actions that fire events on the listener.

      In fact, simply adding a collection listener immediately fires a memory leak, which then continues to creep up as the listener fires.

      iPhone 7 - iOS 15.4

      iPhone 12 - iOS 15.4

      The Malloc 160 bytes is the leak that keeps growing as the listeners get added/fire.
      On a screen that constantly performs update operations (against the same collection that has a listener), the Malloc 32 bytes also starts to creep up quickly.

      Note: Although I'm using the Hermes branch, I'm not using Hermes on iOS, but rather the JSC implementation (:hermes_enabled => false)

      Also note that this may be a false positive, and the memory leak could come from RN itself, but I thought it would be a good idea to review this either way.

      Stacktrace & log output

      Unable to find source-code formatter for language: shell. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      No stack traces, please see screenshots.
      

      Can you reproduce a bug?

      Yes, sometimes

      Reproduction Steps

      • Start the application and add collection listeners that are persistent throughout the app's life cycle.
      • Perform actions that add/remove items from the collections that have listeners
      • The listener callbacks should also perform queries against the listened collections.
      • Monitor the app using XCode memory profiler, and observe leaks ramping up.

      Version

      10.20.0-beta.3

      What SDK flavour are you using?

      Local Database only

      Are you using encryption?

      No, not using encryption

      Platform OS and version(s)

      iOS 15.x

            Assignee:
            kraen.hansen@mongodb.com Kræn Hansen
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: