Re: malloc was optimized out
Re: malloc was optimized out
- Subject: Re: malloc was optimized out
- From: Quincey Morris <email@hidden>
- Date: Mon, 04 Jul 2016 11:55:26 -0700
- Feedback-id: 167118m:167118agrif8a:167118subItQ5Tl4:SMTPCORP
On Jul 4, 2016, at 11:09 , Dmitry Markman <email@hidden> 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 (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden