[opensource-dev] About memory management on macOS 10.12 (Sierra) potentially affecting all viewers

Cinder Roxley cinder at alchemyviewer.org
Fri Jul 8 14:23:34 PDT 2016


Since it’s clear you just want to argue and have no interest in understanding memory management, we’ll leave it at that then. I really doubt the other hundred people subscribed to this list are interested.
 
 
-- 
Cinder Roxley
Sent with Airmail
 

On July 8, 2016 at 3:13:44 PM, Geir Nøklebye (geir.noklebye at dayturn.com <mailto:geir.noklebye at dayturn.com> ) wrote:

 
I cannot see there is anything “advanced”  MRR (manual retain-release) going on in:

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];


insert your viewer code here

[pool release];


That can’t be handled with @autoreleasepool, if you even need to handle it outside the main thread autoreleasepool


In fact the above is a classic example of the old garbage collector in action. 


Geir, 


On 8. jul. 2016, at 21.47, 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/a4ec4285/attachment.htm 


More information about the opensource-dev mailing list