• 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: Memory Managment (copys??)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory Managment (copys??)


  • Subject: Re: Memory Managment (copys??)
  • From: Dominik <email@hidden>
  • Date: Sun, 6 Feb 2005 19:39:48 +0100

I cant see why it should leak either...

Am 06.02.2005 um 19:29 schrieb Erik M. Buck:

NSMutableArray* array = [[NSMutableArray alloc] init];
SOMEObject* object;
int i;

for (i = 0; i < 10; i++)
{
   object = [[SOMEObject alloc] init];
   [object setSomeProperty: i];
   [array addObject: object];
   [object release];
}
/* Do something with the array */
[array release];

I might be missing something, but I don't think this code will leak.

array is allocated and released once.
object is allocated and releases exactly once per loop iteration. The world
is in balance and prosperity may reign.


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


May you always find water and shade (WoT)
Dominik

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: Memory Managment (copys??) (From: "Erik M. Buck" <email@hidden>)

  • Prev by Date: Re: Memory Managment (copys??)
  • Next by Date: Re: Memory Managment (copys??)
  • Previous by thread: Re: Memory Managment (copys??)
  • Next by thread: importing tab-delimited table (newbie)
  • Index(es):
    • Date
    • Thread