• 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: Garbage Collection: memory limits, crash when using "lots" of memory, why?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Garbage Collection: memory limits, crash when using "lots" of memory, why?


  • Subject: Re: Garbage Collection: memory limits, crash when using "lots" of memory, why?
  • From: Martin Wierschin <email@hidden>
  • Date: Fri, 23 Sep 2011 12:40:27 -0700

>> Exceeding the available memory of the garbage collector should not crash, instead your allocations should fail.
>
> When memory allocations fail, apps crash. Like it or not, that's just the way it is. Not sure what the alternative would be - Changing all (!) of our code to handle out-of-memory errors at every method / function call? And then if you were to catch such an error, having to handle it without being able to allocate memory?

I think crashing is a fine behavior when one is really out of memory (eg: it's not even possible to alloc a single vanilla NSObject), or when using Cocoa classes that aren't memory allocators (pretty much everything besides NSData). But in this case, where he's requesting big chunks (10MB at a time), it would be nice if NSMutableData would return nil from its initializers to signal that.

I know it's good to be consistent across the framework, and you really don't want to have to test every NSData/NSMutableData operation that could fail. But if you expect/know you're requesting a larger allocation, it would be nice if there were methods that allowed for error checking instead of undefined behavior (crashing, exceptions, logging, etc).

~Martin

_______________________________________________

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: Garbage Collection: memory limits, crash when using "lots" of memory, why?
      • From: Charles Srstka <email@hidden>
References: 
 >Garbage Collection: memory limits, crash when using "lots" of memory, why? (From: Sean McBride <email@hidden>)
 >Re: Garbage Collection: memory limits, crash when using "lots" of memory, why? (From: Don Quixote de la Mancha <email@hidden>)
 >Re: Garbage Collection: memory limits, crash when using "lots" of memory, why? (From: Joar Wingfors <email@hidden>)

  • Prev by Date: Asynchronous document migration use cases
  • Next by Date: Re: Deploy terminal app
  • Previous by thread: Re: Garbage Collection: memory limits, crash when using "lots" of memory, why?
  • Next by thread: Re: Garbage Collection: memory limits, crash when using "lots" of memory, why?
  • Index(es):
    • Date
    • Thread