CocoaAsyncSocket icon indicating copy to clipboard operation
CocoaAsyncSocket copied to clipboard

GCDAsyncUdpSocket sendData to cause memory leak in IOS9

Open xuanxt opened this issue 10 years ago • 4 comments

Anyone can create a timer send data to self every 0.01s use GCDAsyncUdpSocket, then show the debug navigator. You can see the memory use rapid growth.

Maybe here's the question

[self asyncResolveHost:host port:port withCompletionBlock:^(NSArray *addresses, NSError *error) {
    packet->resolveInProgress = NO;
    packet->resolvedAddresses = addresses;
    packet->resolveError = error;
    if (packet == currentSend)
    {
        LogVerbose(@"currentSend - address resolved");
        [self doPreSend];
    }
}];
dispatch_async(socketQueue, ^{ @autoreleasepool {
    [sendQueue addObject:packet];
    [self maybeDequeueSend];

}});

in this function - (void)sendData:(NSData *)data withTimeout:(NSTimeInterval)timeout tag:(long)tag;

a simple example udpTest.zip

xuanxt avatar Feb 19 '16 09:02 xuanxt

I also met the problem, in ios9,Memory not release

sitale avatar Feb 19 '16 10:02 sitale

@liusibin How did you solve the problem?

xuanxt avatar Feb 22 '16 08:02 xuanxt

+1 I've also the same memory increasing and not releasing problem with the CocoaMQTT Framework base on CGDAsyncSocket in iOS9. Any temporary solutions to fix this problem would be appreciated :) Maybe there is a relation with : GCDAsyncSocket.m:7923:75: 'kCFStreamNetworkServiceTypeVoIP' is deprecated: first deprecated in iOS 9.0 - use PushKit for VoIP control purposes Thanks

imiko avatar Feb 22 '16 22:02 imiko

@puga1024 : I also think there's a problem in that part of the code, I commented here

https://github.com/robbiehanson/CocoaAsyncSocket/issues/390#issuecomment-188453264

with an ugly hack , which seems to have stopped the leak in my case.

eemerge avatar Feb 24 '16 21:02 eemerge