kgn / InAppSettings

InAppSettings provides a view controller that displays the application's Settings.bundle as it appears in the iPhone settings. Allowing the same preferences in app and in the iPhone settings.
MIT License
233 stars 33 forks source link

A few leaks found #1

Open kgn opened 13 years ago

kgn commented 13 years ago

First, a big thanks for this code!! After running my app through Instruments, I found a few leaks. Below is the info I extracted from Instruments. Let me know if you need anything else. LEAKED OBJECT: Malloc 16 bytes EVENT TYPE: Malloc RESPONSIBLE CALLER: [InAppSettingsReaderRegisterDefaults loadFile]

kgn commented 13 years ago

Glad I read this issue before adding this to my project. Personally I would prefer just to remove the "self." and do a direct assignment because all of these seem to be in the init functions anyway (pointers should be nil at this point). When using "self." the setter is used, which retains the object, and you're passing an autoreleased object. If you assign it directly you avoid using an autorelease and the retainCount is balanced in the dealloc regardless of whether the property is "retain" or "assign". If for some reason later the property was changed to "assign" you won't loose the object by doing a direct assignment (because object ins alloc'ed in init, and released in dealloc).

kgn commented 13 years ago

I found some leaks and fixed them. I attached the patch.

patch: https://bitbucket-assetroot.s3.amazonaws.com/keegan3d/inappsettings/20101015/27/InAppSettings.20101014.diff

kgn commented 13 years ago

From and email: I’ve found that Instruments/leak detection is finding a number of leaks, even when using sample app. I’m hoping it is something I am doing incorrectly here. For example, when I init default values from my app delegate, leaks are reported in the in the InAppSetttingsRegisterDefaults loadFile function. There are 12 leaks reported. It appears that the retain count of ‘setting’ is 2 immediately before its release. I’d appreciate any suggestions you may have.

tblack2200 commented 13 years ago

I had posted this original message back on June 2 and was wondering if you would have an updated version of the code soon with the memory leaks fixed?

Thanks

kgn commented 13 years ago

I haven't been writing iOS apps recently so I haven't looked into this issue.

kgn commented 11 years ago

I'll need to look into this, hopefully it's fixed with ARC