[opensource-dev] About memory management on macOS 10.12 (Sierra) potentially affecting all viewers
Cinder Roxley
cinder at alchemyviewer.org
Fri Jul 8 13:36:40 PDT 2016
None of the examples you pasted have anything to do with Apple’s garbage collector, hun. They’re just examples of advanced MRR.
As I already stated, the viewer has never used Apple’s garbage collector. It uses a combination of autorelease pools and MRR which is perfectly fine to do, especially in Objective-C++ where we are not only managing objective-c objects, but C++ objects as well.
--
Cinder Roxley
Sent with Airmail
On July 8, 2016 at 1:47:16 PM, Geir Nøklebye (geir.noklebye at dayturn.com <mailto:geir.noklebye at dayturn.com> ) wrote:
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,
_______________________________________________
Policies and (un)subscribe information available here:
http://wiki.secondlife.com/wiki/OpenSource-Dev
Please read the policies before posting to keep unmoderated posting privileges
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.secondlife.com/pipermail/opensource-dev/attachments/20160708/32f72628/attachment.htm
More information about the opensource-dev
mailing list