问题
Hello I am pretty new to iphone development. I have run my app for the first time using the "Leaks" from "Instruments". It shows me several leaks around 20 the smallest is 32 bytes and there is one with 1KB. I have followed the memory management guidelines, (i (think i) understand how and when to use release, not to use it when adding to autorelease pools, for every copy, retain, init there should be a release,... etc). I don't think I understand the output of the Leaks in instruments. What does "Responsible library" and "Responsible frame" mean. Because there are some classes and methods i never used directly. It also shows NSURLConnection objects which I have realeased in the connectionDidFinishLoading method and also in the error handler method. So tehnically there is no way for them to leak. Are there any good tutorials for debugging memory leaks in instruments or other advice you can give me regarding leaks. Thanks in advance.
Here are the largest 2 leaks.
Leaked Object # Address Size Responsible Library Responsible Frame Malloc 1.00 KB 0x4827400 1024 CFNetwork std::vector >*, std::allocator >*> >::reserve(unsigned long) // i have no idea what this is. Leaked Object # Address Size Responsible Library Responsible Frame Malloc 128 Bytes 5 640 UIKit UIImagePickerLoadPhotoLibraryIfNecessary // so this means UIImagePicker is leaking memory?
The first leak i get
Leaked Object # Address Size Responsible Library Responsible Frame Malloc 128 Bytes 0x442dfd0 128 UIKit UIKeyboardInputManagerClassForInputMode
I don't understand any of those.
And I find it very strange that even an almost empty app with no code added, just a view and a textfield also leaks memory.
回答1:
Here are some i found. If there are others then please add them.
http://www.cimgf.com/2008/04/02/cocoa-tutorial-fixing-memory-leaks-with-instruments http://www.mobileorchard.com/find-iphone-memory-leaks-a-leaks-tool-tutorial
来源:https://stackoverflow.com/questions/3061241/advice-using-leaks-in-instruments-for-noobs