For example if you create your own GCD queue:
self.renderQueue = dispatch_queue_create("com.test.queue", DISPATCH_QUEUE_SERIAL);
Do you have to create an autorelease pool in every block submitted to that queue, using:
@autoreleasepool {
}
?
Or does ARC create it for you? What happens if you don't specify autoreleasepool in your custom queues?
It depends on your usage of autoreleased objects.
Every GCD thread has an outermost autorelease pool, but that pool is drained at a time you cannot control directly (currently the drain occurs when the thread becomes idle, just before it parks itself in the kernel awaiting reuse or reaping).
If your process keeps GCD threads active for long periods of time and/or if you create a large number of autoreleased objects (or very large autoreleased objects) in your blocks, you may wish to create a pool in your blocks to ensure the resources occupied by those objects are freed up earlier.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With