Re: Newbie with stupid question cont.
Re: Newbie with stupid question cont.
- Subject: Re: Newbie with stupid question cont.
- From: Sam Goldman <email@hidden>
- Date: Mon, 18 Mar 2002 22:44:57 -0800
On 3/18/02 10:32 PM, "email@hidden" <email@hidden> wrote:
>
> I'm asking because the following code crash if I uncomment the [sReturn
>
> release]:
>
>
>
> - (NSArray *) getInterfaceIPList{
>
> NSArray *ifaces;
>
> NSMutableArray *arrReturn;
>
> NSString *sReturn;
>
> int x;
>
>
>
> ifaces = [self getInterfaceList];
>
> arrReturn = [NSMutableArray arrayWithCapacity:[ifaces count]];
>
> for(x=0 ; x < [ifaces count]; x++){
>
> sReturn = [NSString stringWithFormat:@"%@ (%@)", [ifaces
>
> objectAtIndex:x], [self getIPForInterface:[ifaces objectAtIndex:x]]];
>
> [arrReturn addObject:sReturn];
>
> [sReturn release]
>
> }
>
> return arrReturn;
>
> }
>
>
Yep. Symptoms would vary depending upon the lifetime of arrReturn
>
versus the time to the next pop of the autorelease pool, but this should
>
crash eventually in one way or another.
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.
- Sam
--
Windows is a 32-bit patch to a 16-bit shell for an 8-bit operating system
written for a 4-bit processor by a 2-bit company without 1 bit of sense.
_______________________________________________
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.