pokeb / asi-http-request

Easy to use CFNetwork wrapper for HTTP requests, Objective-C, Mac OS X and iPhone
http://allseeing-i.com/ASIHTTPRequest
Other
5.78k stars 1.41k forks source link

ASIInputStream leaks on iOS7 compiled by Xcode 5.0 #378

Open msching opened 10 years ago

msching commented 10 years ago

dealloc is not called on iOS7 when a request has postbody. Profile the iphone sample with leaks, click upload tab and upload then you will find ASIInputStream is leaking.

hisaoka commented 10 years ago

I check the memory leak in my environment as well. People who are looking how to handle someone do not come?

mjohnson12 commented 10 years ago

The leak is because ASIInputStream is being cast to a CFReadStreamRef but ASIInputStream does not derive from NSInputStream it just wraps it.

My Solution is to get rid of ASIInputStream and create a NSInputStream instead in the ASIHTTPRequest startRequest: method.

It breaks using the metrics that ASIInputStream records but I wasn't using them.

I'm using a fairly old version of ASIHTTPRequest v.1.6.2 so your milage may vary.

msching commented 10 years ago

it works! thanks a lot! BTW, if I subclass NSInputStream using this: https://github.com/bjhomer/HSCountingInputStream/blob/master/HSCountingInputStream/HSCountingInputStream.m, will also fix the leaks and make the post request working. But it is overriding undocumented methods. Is there any risks when my app is submitted to Appstore?

heroims commented 10 years ago

https://github.com/pokeb/asi-http-request/pull/382