1

I know that there are lots of posts about memory leaks. Now i am reading those.

But maybe there some people could give me some tips how to find in which controller or even which object is leaking. Because now i have stack trace with object names like 0xcvf34 and responsoble framework which is

Leaked Object   #   Address Size    Responsible Library Responsible Frame
 __NSCFString,1 0xcvf34 32 Bytes    Foundation  -[NSPlaceholderString initWithBytes:length:encoding:]

And there lots of more

What could be my strategy ? Because to find which NSString is leaking is really hard as there lots of code.

Am using apple instruments.

Streetboy
  • 4,351
  • 12
  • 56
  • 101
  • One very important thing is: the `NSString` you mention is probably not *leaking* but *leaked*. You have to walk up the allocation trace to find the culprit (the owner). – jv42 Feb 03 '12 at 08:09

2 Answers2

3

Select the line and look into the side bar which will tell you which class it belongs to.

Vignesh
  • 10,205
  • 2
  • 35
  • 73
  • It don't say it for which class it belongs to. Maybe i don't now how to configure right settings to instruments ? – Streetboy Feb 03 '12 at 07:45
  • May be double click the line which will lead some other root cause which may help you. – Vignesh Feb 03 '12 at 07:50
0

It's very common that Foundation objects start leaking and sadly most of the time there's nothing you can do about it.

If you want your app to get approved at the AppStore, the rule would be to fix the leaks from your code itself, that means, the Responsible would be "YourViewController" instead of, for i.e., "Foundation", since Foundation leaks means "its Apple's fault, not yours".

Take a look at this post, it may give you some directions for this topic:

http://www.raywenderlich.com/2696/how-to-debug-memory-leaks-with-xcode-and-instruments-tutorial

codingcthulhu
  • 253
  • 2
  • 9
  • 1
    *It's very common that Foundation objects start leaking and sadly most of the time there's nothing you can do about it.* ??? a) I don't find it's "very common". The project I am working on now has **one leak**. b) File a bug. c) Leaks points out the image that made the allocation, not the library that is responsible for the ref count imbalance. – justin Feb 03 '12 at 08:03
  • Take a look at the 2nd answer http://stackoverflow.com/questions/3384537/nsxmlparser-memory-leak-on-ios-4-0-not-nscfstring . Thats what I mean when I say "Apple's fault" and "very common". It's awesome that you have one leak in your project, mine has 2 related to ASIHTTPRequest. Anyways, my point is that I do not spend time trying to find a workaround for Apple's libraries bugs in order to reduce leakage, unless the leakage has a nice amount of kb. – codingcthulhu Feb 03 '12 at 08:36
  • @codingcthulu Yes, I know Apple ships software that leaks -- I've been using their libs for many years. These bugs come and they go. My point was that it's just not "very common". The bug you linked is (naturally) very isolated. Although defects do get through, the system libraries are certainly cleaner than typical programs from app-land. And that's coming from somebody who takes leaks very seriously. – justin Feb 03 '12 at 09:00