[cfe-dev] Memory leak analysis and self destructing objects

Ted Kremenek kremenek at apple.com
Wed Jul 23 09:19:10 PDT 2008


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



More information about the cfe-dev mailing list