[cfe-dev] Memory leak analysis and self destructing objects
Jean-Daniel Dupas
devlists at shadowlab.org
Wed Jul 23 16:20:14 PDT 2008
Le 23 juil. 08 à 18:19, Ted Kremenek a écrit :
>
> On Jun 20, 2008, at 1:42 AM, Nikita Zhuk wrote:
>
>> For example:
>> -(void)awakeFromNib
>> {
>> NSWindow *window = [[NSWindow alloc]
>> initWithContentRect:NSMakeRect(0,0,100,100)
>> styleMask:NSTitledWindowMask|NSClosableWindowMask backing:
>> NSBackingStoreBuffered defer:NO]; // isReleasedWhenClosed is set to
>> YES by default
>> [window orderFrontRegardless];
>>
>> // False memory leak reported - window will be released when user
>> closes it
>> }
>
> I'm reopened this issue as a new Bugzilla report:
>
> http://llvm.org/bugs/show_bug.cgi?id=2588
>
> It turns out that an NSWindow object doesn't self-own itself until it
> is displayed, so the code snippet above is actually a real leak.
> Right now the analyzer has been tweaked to consider an NSWindow object
> to be self-owning once it is initialized, but this is not correct.
> The bugzilla report has more information.
>
> Ted
-orderFrontRegardless is a method that displays the window, so no,
this code snippet is not a leak.
More information about the cfe-dev
mailing list