Re: Garbage Collection: memory limits, crash when using "lots" of memory, why?
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 13:18:28 -0700
>> 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).
>
> Well, I’m not sure I’d technically consider that being inconsistent across the framework in the first place, since those are two different cases — if you’re so badly out of memory that you can’t even allocate an NSObject, then it’s going to be the +alloc method that fails. However, if it’s just allocating a big chunk that’s failing, then +[NSMutableData alloc] is going to work fine, and it’s going to be one of the -initWith... methods that will actually fail.
Right, I was just referring to -[NSMutableData initWithLength:] and other other operations that do/may allocate memory chunks, like -[NSMutableData increaseLengthBy:]. I have no qualms about any +[NSObject alloc] method crashing if memory is exhausted.
~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
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>) |
| >Re: Garbage Collection: memory limits, crash when using "lots" of memory, why? (From: Martin Wierschin <email@hidden>) |
| >Re: Garbage Collection: memory limits, crash when using "lots" of memory, why? (From: Charles Srstka <email@hidden>) |