Re: Instruments Allocation Leak Question
Re: Instruments Allocation Leak Question
- Subject: Re: Instruments Allocation Leak Question
- From: Hamish Allan <email@hidden>
- Date: Wed, 02 Mar 2011 23:44:20 +0000
At a guess, NSPathStore2 does a fair bit of caching. If I were
designing a string class specifically for paths, I would make it a
linked list and keep instances around on a most-recently-used basis,
because the next path you need will likely share a common prefix with
the last one you used.
H
On 2 March 2011 23:26, Laurent Daudelin <email@hidden> wrote:
> I've read with great interest the blog from Bill Bumgarner (bbum) titled "When is a Leak not a Leak? Using Heapshot Analysis to Find Undesirable Memory Growth". It helped me find some leaks but after multiple iterations, I'm stumped on some leaks that I can't seem to resolve.
>
> For instance, when I examine some heapshots, the instances that use the most space after marking the heap are NSPathStore2 instances. Specifically, there are some instances of this class that are left over after I do an iteration in my code that should not leave any instance of that class hanging after it has run. In each iteration, there are always 14 instances that still live, each consuming between 200 and 500 bytes. Not much as it is about 4KB. But still, I'd like to understand why they still "live" after my code executed.
>
> Further, when I double-click the faulty instruction in the stack in the extended detail of Instruments, shouldn't this very line be selected automatically? It is not in my case. Instead, my source code is opened and I see a few lines that are highlighted in gray with a percentage at the right.
>
> In any case, it seems that all instances that still live originate from the same line of code, in my code:
>
> pathToCompare = [destinationDirectoryPath stringByAppendingPathComponent:pathPartToAdd];
>
> That's the only line around that deals with path. As you can see, there is no alloc/init, copy or retain in my code. When I call "stringByAppendingPathComponent:", the stack trace looks like this in Instruments:
>
> 4 Foundation -[NSPathStore2 stringByAppendingPathComponent:]
> 2 Foundation NSAllocateObject
> 1 libobjc.A.dylib _internal_class_createInstanceFromZone
> 0 libSystem.B.dylib calloc
>
> So, what's happening here? Where is the leak and what can I do about it?
>
> -Laurent.
> --
> Laurent Daudelin
> AIM/iChat/Skype:LaurentDaudelin http://www.nemesys-soft.com/
> Logiciels Nemesys Software email@hidden
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden