Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix retaining cycle caused by timer on SuperpoweredIOSAudioIO #533

Closed
wants to merge 1 commit into from

Conversation

luizv
Copy link

@luizv luizv commented Nov 9, 2018

Commit Description

  • Fix implementation of the stopTimer to prevent retaining cycles
  • Change stopTimer from a NSTimer to dispatch_source_t object

Comment

  • On a personal project I notice that instances of SuperpoweredIOSAudioIO could never be deallocated because of a strong reference kept by NSTimer. Dealloc would never be called.

  • I changed the implementation of the stopTimer (originally a NSTimer) to a be a dispatch_source_t object. This way no strong reference to self was kept.

  • It was a simple fix, that maintains the same intended functionality (calling everySecond method every second while SuperpoweredIOSAudioIO exists), with the benefit of preventing this memory leak.

Virtually no impact on compatibility
Also this change doesn't impact on compatibility. dispatch_source_t is available on:
iOS 4.0+, macOS 10.6+, tvOS 9.0+, watchOS 2.0+

- Fix implementation of NSTimer to prevent retaining cycles
- Change NSTimer to dispatch_source_t object
Copy link

@reddotrapbeat reddotrapbeat left a comment

Choose a reason for hiding this comment

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

Okay

@gaborszanto
Copy link
Member

Thanks for discovering this issue. The next build will have a simple [self release] after the timer is created. I think it's more compact solution.

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.

3 participants