• 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: Question about garbage collection
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about garbage collection


  • Subject: Re: Question about garbage collection
  • From: Ben Haller <email@hidden>
  • Date: Sun, 3 Jan 2010 21:21:27 -0500

On 3-Jan-10, at 8:31 PM, Bill Bumgarner wrote:

On Jan 3, 2010, at 2:45 PM, Graham Cox wrote:

On 04/01/2010, at 4:59 AM, Michael Abendroth wrote:

When I write something like:

while (true) {
NSString *s = [[NSString alloc] initWithString:@"applejuice"];
}

Will s be garbage collected? If not, how can I make sure it does get
deallocated by garbage collection.


As written, it's academic, as your program will never proceed beyond this point, and will eventually crash with an out of memory error.

In Leopard, definitely.

In Snow Leopard, maybe not. It is a rather contrived test case, but it is much more difficult to outrun the collector in Snow Leopard than it was in Leopard.

Bill, I for one would like to hear a bit more about this. What has changed in SL? Why would it ever be possible to outrun the collector? If the limit of memory is being reached, can't it always just do an immediate, synchronous collection before the call to +alloc returns? I'd love to have a better understanding of what's going on under the hood here...


Ben Haller
Stick Software


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Question about garbage collection
      • From: Quincey Morris <email@hidden>
References: 
 >Question about garbage collection (From: Michael Abendroth <email@hidden>)
 >Re: Question about garbage collection (From: Graham Cox <email@hidden>)
 >Re: Question about garbage collection (From: Bill Bumgarner <email@hidden>)

  • Prev by Date: Re: Question about garbage collection
  • Next by Date: Problem chaining initialization methods
  • Previous by thread: Re: Question about garbage collection
  • Next by thread: Re: Question about garbage collection
  • Index(es):
    • Date
    • Thread