[opensource-dev] About memory management on macOS 10.12 (Sierra) potentially affecting all viewers
Geir Nøklebye
geir.noklebye at dayturn.com
Fri Jul 8 12:47:09 PDT 2016
> Cinder Roxley said:
> The viewer has never used the garbage collector so it?s not an issue.
Why is it that in llopenglview-objc.mm, as en example, we have statement like:
NSOpenGLPixelFormat *pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attrs] autorelease];
or
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
while Apples ARC migration guidelines states:
You cannot explicitly invoke dealloc, or implement or invoke retain, release, retainCount, or autorelease.
You can’t invoke dealloc.
Custom dealloc methods in ARC do not require a call to [super dealloc] (it actually results in a compiler error). The chaining to super is automated and enforced by the compiler.
Or in llwindowmacosx-objc.mm we have code such as:
bool copyToPBoard(const unsigned short *str, unsigned int len)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
NSPasteboard *pboard = [NSPasteboard generalPasteboard];
[pboard clearContents];
NSArray *contentsToPaste = [[NSArray alloc] initWithObjects:[NSString stringWithCharacters:str length:len], nil];
[pool release];
return [pboard writeObjects:contentsToPaste];
}
Apple’s documentation specifically says how to rewrite this construct for ARC.
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSAutoreleasePool_Class/index.html#//apple_ref/occ/cl/NSAutoreleasePool
So all this code needs to be rewritten to support ARC or it will not run or fail on 10.12.
Geir Nøklebye,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.secondlife.com/pipermail/opensource-dev/attachments/20160708/e445fa17/attachment.htm
More information about the opensource-dev
mailing list