Avoid auto-realized objects, best practices or busting?

I'm just curious about the following: when I write code, I always try to manage my memory by sticking to unauthorized objects. I know this means that the objects do not hang around in the pool, but I was just curious if this is done as a whole, is this a good practice or just brute force?

// User Managed Memory
NSSet *buttonSizes = [[NSSet alloc] initWithObjects:@"Go", @"Going", @"Gone", nil];
[barItemLeft setPossibleTitles:buttonSizes];
[barItemRight setPossibleTitles:buttonSizes];
[buttonSizes release];

.

// Autoreleased Memory
NSSet *buttonSizes = [NSSet setWithObjects:@"Go", @"Going", @"Gone", nil];
[barItemLeft setPossibleTitles:buttonSizes];
[barItemRight setPossibleTitles:buttonSizes];
+5
source share
6 answers

. , , . , , , . ( retain release), , .

, iPhone - , - , . Objective-C, Foundation Cocoa ( ), NeXTcube, 16 ( 64). iPhone 3, EOL , 128 .

iPhone - runloop, , . . , , , :

  • , ( ARPool)
  • , . .

. , , . , , , , "--". "--", ARPools, .

, , , , ( ) , , .

# 2

, , autorelease. , " " " " iOS. , , . : 20 , , iDevices.

+8

( ), . , , . - (, ). iPhone.

, , .

+3

, . , , - , . , .

+2

. . , barItem* , 100% , , .

, , , runloop, runloop , . IPhone - , . , : NSNumber , , . 100 NSStrings 0,065% iPhone 3GS. , . , , .

+1

. , objective-c AudioUnit ( ), . , .

, ,

+1

, : . , , , "", , , , .

Premature optimization is a great way to waste time. Maybe in the end you know that your solution is elegant, but it may be that a simpler solution works just as well.

+1
source

All Articles