Skip to content

Retain cycle between SEGAnalytics and SEGIntegrationsManager #1054

@gpambrozio

Description

@gpambrozio

When SEGAnalytics is initialized, it creates and strongly retains a SEGIntegrationsManager, passing self to SEGIntegrationsManager's initializer, which then retains it strongly, thus creating a retain cycle.

This becomes an issue for our project as we sometimes switch environment and they have different keys so we have to re-create SEGAnalytics. When we do this the old one still sticks around and we then start to send multiple events for application events as the old SEGAnalytics is still getting notifications from the notification center.

Relevant declarations:

https://github.com/segmentio/analytics-ios/blob/master/Segment/Classes/SEGAnalytics.m#L28
https://github.com/segmentio/analytics-ios/blob/master/Segment/Internal/SEGIntegrationsManager.m#L67

Oh, the irony: https://github.com/segmentio/analytics-ios/blob/master/Segment/Classes/SEGAnalytics.m#L53

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions