• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Newbie with stupid question cont.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie with stupid question cont.


  • Subject: Re: Newbie with stupid question cont.
  • From: Ondra Cada <email@hidden>
  • Date: Tue, 19 Mar 2002 14:13:58 +0100

On Tuesday, March 19, 2002, at 07:44 , Sam Goldman wrote:

for(x=0 ; x < [ifaces count]; x++){
sReturn = [NSString stringWithFormat:@"%@ (%@)", [ifaces
objectAtIndex:x], [self getIPForInterface:[ifaces objectAtIndex:x]]];
[arrReturn addObject:sReturn];
[sReturn release]
}


And you probably don't want to have a bunch of autoreleased objects in a
loop. The autorelease pool will get really big and slow down your app. If
performance is an issue, then you should avoid autoreleased objects being
created inside of loops which count potentially happen a bunch of times.

Nope. quite the contrary. With a vast majority of loops (depends on other conditions too, but a rough guess might be up to XXX iterations) autoreleasing makes no problem at all, and the slowing down is unnoticeable.

If the loop is to be iterated many times indeed, the solution is still autoreleasing, this time with a local loop:

for (...many times...) {
NSAutoreleasePool *pool=[[NSAutoreleasePool alloc] init];
...
[pool release];
}
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
2K Development: email@hidden http://www.2kdevelopment.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Newbie with stupid question cont.
      • From: Don Rainwater <email@hidden>
References: 
 >Re: Newbie with stupid question cont. (From: Sam Goldman <email@hidden>)

  • Prev by Date: Re: Stop a NSTask
  • Next by Date: Re: Setting fixed pitch font (temporary) for NSTextView object
  • Previous by thread: Re: Newbie with stupid question cont.
  • Next by thread: Re: Newbie with stupid question cont.
  • Index(es):
    • Date
    • Thread