Reputation: 228
While normal queues created for background threads using GCD are needing the dispatch_release to free up the memory for the object, would the same need to be done for getting the global queue since deallocating the global queue could cause issues with the operating system I ask: is a dispatch_release needed for the object holding the reference to a queue gotten by dispatch_get_global_queue or is a dispatch_source_cancel sufficient enough?
To give more depth to this question, I'm using the global queues to setup timers and have them run and fire off an event and this project is non-ARC'd.
Upvotes: 0
Views: 292
Reputation: 3681
The naming convention for the GCD API is derived from the one for CoreFoundation:
Memory Management Programming Guide for Core Foundation
In particular the "Get Rule" therein answers your question, the API is named dispatch_get_global_queue and not dispatch_create_global_queue so it does not confer a reference to the returned object.
Upvotes: 0
Reputation: 138251
You didn't create the object, so you don't own it. Consequently, you must not release it.
If you pass it to an object that will keep a reference to it, this object should dispatch_retain
the queue when it gets it, and dispatch_release
it when it's done.
Upvotes: 7