On Jul 4, 2016, at 11:09 , Dmitry Markman <dmark...@mac.com> wrote:
> 
> The compiler "knows" how malloc works, and is allowed to optimize as if it 
> never fails. 

I don’t know the answer, but it seems to me at least possible that it didn’t 
fail. It’s at least possible that it gave you an unmapped virtual allocation of 
the size you asked for.

Under that theory, the reason for different behavior in a release build would 
be that it chooses to omit availability checking, perhaps because determining 
the amount of “real” memory is subtle and would be an unacceptable overhead. 
You could find out for sure by looking at the Darwin source code, I suppose.

Incidentally, what pointer does it return in the release build? Does it look 
like a valid pointer? Can it be used as a valid pointer (e.g. for setting byte 
0 of the block to something)?

Also, the 48 bits of memory address space your block consumes is possibly 
within the range of what address space is normally available to apps. What 
happens if you request a much larger amount (e.g. 2 * 64 - 1)?

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (Xcode-users@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/xcode-users/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to