How can a moderately sized memory allocation fail in a 64 bit process on Mac OS X?

前端 未结 6 1689
眼角桃花
眼角桃花 2021-01-02 01:30

I\'m building a photo book layout application. The application frequently decompresses JPEG images into in-memory bitmap buffers. The size of the images is constrained to 10

6条回答
  •  囚心锁ツ
    2021-01-02 02:04

    initWithBytes:length: tries to allocate its entire length in active memory, essentially equivalent to malloc() of that size. If the length exceeds available memory, you will get nil. If you want to use large files with NSData, I'd recommend initWithContentsOfMappedFile: or similar initializers, as they use the VM system to pull parts of the file in and out of active memory when needed.

提交回复
热议问题