CocoaAsyncSocket icon indicating copy to clipboard operation
CocoaAsyncSocket copied to clipboard

memory leak

Open jseanj opened this issue 10 years ago • 12 comments

When I use the method "- (void)readDataWithTimeout:(NSTimeInterval)timeout tag:(long)tag", and I sent 10 bytes/0.1s to the socket from server-side, I found memory leak.

Use Instruments tool (in XCode) to check memory leak. I saw GCDAsyncReadPacket not release.

When setting "currentRead = nil", but the memory pointed by currentRead is not released and its reference count is not zero.

jseanj avatar Dec 17 '15 08:12 jseanj

I also encountered the same problem. But only in iOS9

germ1107 avatar Dec 19 '15 03:12 germ1107

resolving...

在 2015-12-19 11:08:47,"germ1107" [email protected] 写道:

I also encountered the same problem. But only in iOS9

— Reply to this email directly or view it on GitHub.

ochenkai avatar Dec 23 '15 09:12 ochenkai

Any one knows what's going on ? Does it solved?

laputaIs avatar Dec 25 '15 02:12 laputaIs

Does it solved?

germ1107 avatar Dec 31 '15 09:12 germ1107

Even I have problem and it is leading to crash .. Any kind of help ll ve much appreciated Thank you

Prakashhadapad avatar Jan 01 '16 12:01 Prakashhadapad

Hey,i find a answer that says it's about "Xcode memory usage feature ", https://github.com/robbiehanson/CocoaAsyncSocket/issues/390 but i'm not sure whether it's the same problem .

laputaIs avatar Jan 18 '16 03:01 laputaIs

I'm not sure if it's related to this specific leak, but I'm getting a memory leak with GCDAsyncUdpSocket sendData:toHost port withTimeout tag.

I have a simple test app to re-create the problem if someone wouldn't mind looking into it.

F53OSCLeakTest.zip

Enigma644 avatar Jan 23 '16 09:01 Enigma644

I'm also getting a memory leak in my app when running on an iOS 9 device.

tsznober avatar Feb 19 '16 14:02 tsznober

I am also getting a memory leak. Testing shows that memory usage increases with every write on a server socket. The memory is released if the client disconnects. Is there a method to flush the read and/or write buffer?

deannerene avatar Apr 11 '16 01:04 deannerene

Does it solved?I need your help.

yataoSang avatar May 11 '16 08:05 yataoSang

@Enigma644 @deannerene

I'm also getting massive memory increase without being freed on GCDAsyncUdpSocket sendData:toHost port withTimeout tag.

To further confirm this, I wrote a test method in Swift 3 (Xcode 8 beta 4):

let data = Data(bytes: [00])
for _ in 0...500000 {
    UDPSock.send(data, toHost: "192.168.0.150", port: 8001, withTimeout: 2, tag: 0)
}

Then watched my app's debug stats and within seconds memory usage increased to 4GB and stopped responding.

I paused execution in Xcode and looked at the objects that were obviously being created in large numbers and these showed up (and their instance count in parentheses):

  • App → GCDAsyncUdpSendPacket (433205)
  • Foundation → _NSInlineData (467712)
  • libswiftFoundation.dylib → _SwiftNSData (433205)
  • CoreFoundation →
    • NSArray (Object Storage) (34806)
    • NSMutableArray (34821)
    • NSMallocBlock (1262800)
  • libswiftCore.dylib → _NSContiguousString (398769)

Inspecting the contents of some of these elements, it was clear that many contained assets related to the packet being sent, such as NS data containing the IP address etc.

orchetect avatar Aug 06 '16 02:08 orchetect

This issue has been marked as stale, it will be closed automatically if there is no further activity.

github-actions[bot] avatar Mar 09 '20 00:03 github-actions[bot]