Re: 'leaks' tool is inconsistent under otest
Re: 'leaks' tool is inconsistent under otest
- Subject: Re: 'leaks' tool is inconsistent under otest
- From: "Jonathan del Strother" <email@hidden>
- Date: Tue, 8 Jul 2008 20:25:13 +0100
On Tue, Jul 8, 2008 at 7:23 PM, Bill Bumgarner <email@hidden> wrote:
> On Jul 8, 2008, at 10:29 AM, Jonathan del Strother wrote:
>>
>> I have a framework which is tested with otest. On exit, we test for
>> leaks, using much the same methodology as here -
>> http://www.cocoabuilder.com/archive/message/xcode/2008/5/26/21885
>>
>> The results are a bit random. It quite often misses leaks, only to
>> find them again in the next test run, despite having purposefully
>> introduced leaks that are quite clearly always present.
>>
>> Any guesses why I'm seeing this non-deterministic behaviour?
>
> Leaks works by scanning memory, looking for stuff that might be references
> to objects (where "object" means "an allocated hunk of memory" and not
> limited to "an Objective-C object"). Leaks simply scans every 4 bytes (32
> bits, do the math for 64) to see if said bytes contain a value that could be
> construed as a pointer to somewhere. It has no knowledge of the layout of
> data structures, etc.
>
> As such and because the leaks implementation quite explicitly tries to
> minimize false positives (thus suffering from more false negatives), leaks
> will often report inconsistent sets of leaks between runs because of garbage
> left in memory. In some cases, it may never find a particular leak because
> some fixed pattern of execution happens to consistently leave a reference
> behind that is never overwritten.
>
> Fortunately, malloc offers the ability to scribble on memory before / after
> blocks are allocated / free'd. This vastly increases the accuracy of leak
> detection at the cost of performance (not a huge amount, though -- nothing
> like, say, gmalloc).
>
> See x-man-page://malloc
>
Thanks for the suggestion - I'll try scribbling out tomorrow and see
what happens...
_______________________________________________
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