Conversation
This reduces the number of leaks related to dispatch objects.
|
@indutny, @georgekola please review |
|
The question is, how could it be leaking if the handler is always executed, or |
|
I profiled the app with and without the changes in this PR, and with the original code Instruments showed some dispatch-related leaks, and with the changes it did not. The "Call Tree" section of the Leaks instruments lead me to this method, this is why I added the weak reference, and retested the app. Looked at |
|
@cristiankocza I'm not sure which documentation you are referring here: May I ask you to post a complete stack trace of the leak? |
|
From the doxygen documentation of the /*!
* @function dispatch_source_set_event_handler_f
*
* @abstract
* Sets the event handler function for the given dispatch source.
*
* @param source
* The dispatch source to modify.
* The result of passing NULL in this parameter is undefined.
*
* @param handler
* The event handler function to submit to the source's target queue.
* The context parameter passed to the event handler function is the current
* context of the dispatch source at the time the handler call is made.
* The result of passing NULL in this parameter is undefined.
*/
__OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
void
dispatch_source_set_event_handler_f(dispatch_source_t source,
dispatch_function_t handler); |
|
This seems to contradict the man page... Gosh, Apple! What do you think about using |
|
That might work, however I'd also recommend the |
|
Ok, let's do both. |
|
@indutny can you please check if the timer tests run fine with this change. We are finding leaking on iOS 8.4.x and hence want it resolved. |
|
Appears to be working fine: |
|
Ok, pasting the source code of libdispatch-442.1.4 (latest Apple has made available so far), calling with a handler of NULL correctly clears the handler as the man page says -- the header file has apparently not been updated cc @cristiankocza @indutny @kostiadombrovsky @dhruvilv void DISPATCH_ALWAYS_INLINE |
This reduces the number of leaks related to dispatch objects.