bugsnag / bugsnag-cocoa

BugSnag error monitoring & exception reporter for iOS, macOS, tvOS and watchOS
https://docs.bugsnag.com/platforms/ios
MIT License
236 stars 129 forks source link

Loadconfig memory leak #1536

Open EricDuport opened 1 year ago

EricDuport commented 1 year ago

Describe the bug

a configuration load is enough to have a memory leak.

Steps to reproduce

  1. Implements 6.X.X SDK
  2. Get configration by BugsnagConfiguration.loadConfig()
  3. Launch instruments
  4. Observe memory leak

Environment

Capture d’écran 2023-03-21 à 14 30 33
matthewjhowells commented 1 year ago

Hi Eric,

Thanks for reaching out, and apologies for the delay in replying.

We have investigated this internally, and while we have been able to reproduce the memory leak you have reported, we have not been able to isolate whether BugSnag is the cause of this memory leak. Essentially, while testing we have found that Xcode Instruments is saying non-instantiated items are being leaked, with this also occurring when BugSnag is not doing anything at all. This suggests to us that these memory leaks may be getting mis-reported by the Xcode instruments tool.

We would like to continue investigating this and would be interested to know if you use BugsnagNetworkRequestPlugin in you application?

iMac0de commented 1 year ago

Hello Matthew,

I work with Eric and will take over this issue.

I confirm we use the BugsnagNetworkRequestPlugin in our applications (we have three apps currently using BugSnag with this issue).

johnkiely1 commented 1 year ago

Hi @iMac0de, we have just released a new version bugsnag-cocoa v6.27.0 which should remove the need to generate a URLSession when copying a configuration.

In the process we have also discovered an additional issue which ultimately is due to a leak in Apple's code. However, when Bugsnag-Networking is added, we swizzle this method, so any time anyone creates a URLSession (rather than using the default one), our swizzled method ends up in the stack trace when the profiler detects a leak, and then it looks like we’re the ones causing the issue. Trying to address this is still on our backlog.

I would suggest to upgrade to v6.27.0 when convenient and let us know how you get on, as it should hopefully improve it for you.