Skip to content

Strong memory cycle fixes#111

Merged
dsrees merged 4 commits intodavidstump:masterfrom
darrenclark:strong-memory-cycle-fixes
Aug 30, 2018
Merged

Strong memory cycle fixes#111
dsrees merged 4 commits intodavidstump:masterfrom
darrenclark:strong-memory-cycle-fixes

Conversation

@darrenclark
Copy link
Contributor

Fixes #109

Fixes strong reference cycles by using weak, following these "rules":

  • Socket owns Channels (with Channel having a weak reference back to Socket)
  • Channel owns Pushes (with Push having a weak reference back to Channel)
  • Socket / Channel own PhxTimers, used weak in callback blocks to break the strong reference cycle
    • In addition, Socket / Channel now also reset() their timers in deinit

Copy link
Collaborator

@dsrees dsrees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. Thanks for the fix!

})

it("should not introduce any retain cycles", closure: {
weak var channel = Channel(topic: "topic", params: ["one": 2], socket: mockSocket)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thank you for not only fixing the issue but also providing test cases with it

@dsrees dsrees merged commit e300027 into davidstump:master Aug 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants