• 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: malloc was optimized out
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: malloc was optimized out


  • Subject: Re: malloc was optimized out
  • From: Steve Sisak <email@hidden>
  • Date: Mon, 04 Jul 2016 20:12:49 -0400

On Jul 4, 2016, at 7:37 PM, Quincey Morris <email@hidden> wrote:

I think the only way the allocator will know if the requested memory is available to this app is to try writing to it. I dunno what the C language experts think, but this suggests to me that you could try using calloc instead for exactly that reason. It’d be a lot slower for large memory blocks, but if it returns nil on failure to write then that should be what you want to know.

Actually, this is false — see the link I just sent to Dmitry:

https://developer.apple.com/library/prerelease/content/documentation/Performance/Conceptual/ManagingMemory/Articles/MemoryAlloc.html#//apple_ref/doc/uid/20001881-98355

a large calloc() is preferred because it simply allocates uninitialized address space which is zeroed by the VM system automatically when accessed.

But (and this answer may answer Dmitry’s question) calloc/malloc only allocates the address space — the actually failure may not occur until you run out of swap space.

I think there may be more information in the guidelines, but don’t have time to re-read the full document at the moment.

Dmitry, you should.

HTH,

-Steve

 _______________________________________________
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

  • Follow-Ups:
    • Re: malloc was optimized out
      • From: Steve Sisak <email@hidden>
References: 
 >malloc was optimized out (From: Dmitry Markman <email@hidden>)
 >Re: malloc was optimized out (From: Clark Cox <email@hidden>)
 >Re: malloc was optimized out (From: Dmitry Markman <email@hidden>)
 >Re: malloc was optimized out (From: Clark Cox <email@hidden>)
 >Re: malloc was optimized out (From: Dmitry Markman <email@hidden>)
 >Re: malloc was optimized out (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: malloc was optimized out
  • Next by Date: Re: malloc was optimized out
  • Previous by thread: Re: malloc was optimized out
  • Next by thread: Re: malloc was optimized out
  • Index(es):
    • Date
    • Thread