Re: Breakpoint when NSString gets set to a certain value?
Re: Breakpoint when NSString gets set to a certain value?
- Subject: Re: Breakpoint when NSString gets set to a certain value?
- From: Kyle Sluder <email@hidden>
- Date: Fri, 19 Jul 2013 23:59:24 -0700
On Fri, Jul 19, 2013, at 10:45 PM, Jerry Krinock wrote:
> The 'leaks' tool has identified several NSString objects that my app is
> leaking. But neither 'leaks' nor Instruments > Leaks identifies the
> responsible frame in my code. The 'leaks' tool gives me the string
> value, but I still need more clues to find it in my code.
>
> This string appears to be the 'path' of a file:// NSURL, which is also
> leaking, so I surmise it is actually the NSURL which is leaking.
>
> Does anyone know a method in NSURL or NSString in which I could set a
> breakpoint with a condition to trigger whenever its path or string gets
> set to a certain value?
>
> Thanks,
>
> Jerry
>
> I've tried the following Symbolic Breakpoints…
>
> -[NSString initWithString:]
I wouldn't expect this to ever get called, since NSString is a class
cluster, and -[NSString alloc] probably doesn't actually do any
allocation.
> -[NSURL initWithScheme:host:path]
This isn't the designated initializer for NSURL. According to the
documentation, the designated initializer is
-initWithString:relativeToURL:.
Of course, since NSURL is toll-free bridged to CFURLRef, there's a
chance you'll never see that method get called either.
> -[__NSCFString init]
This method does not exist. In fact, as far as I can tell, there are no
initializers for __NSCFString *at all*:
(lldb) target modules lookup -r -n '__NSCFString init'
(lldb)
>
> with *no* breakpoint conditions, but, to my surprise, I get no breaks at
> all! Maybe Apple has optimized these methods so much that they only
> really exist in the documentation nowadays?
It's neither here nor there; your approach does not sound like the most
efficient way to debug your actual problem, which is far more likely
that someone is holding on to your NSURL object longer than they should
be. Have you tried running under the Allocations instrument?
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden