Skip navigation.
 
mlRe: Re: NSData dataWithContentsOfMappedFile with huge files?
FROM : Michael Ash
DATE : Sun Aug 27 14:48:35 2006

On 8/27/06, Cameron Hayne <<email_removed>> wrote:
> On 25-Aug-06, at 4:54 PM, Shawn Erickson wrote:
>
> > If NSData does a straight contiguous mapping (which it likely has to
> > do given its API) the limit is just a little over 2 GiB in size
> > (assuming a clean application heap).
>
> Hmm, that makes sense. I guess it was wishful thinking - I was hoping
> that it might do something super-smart behind the scenes such that it
> could cover more than that as long as you didn't ask for too large a
> chunk of 'bytes' at any one time.


Most use of NSData doesn't involve asking for a chunk, though. As soon
as you invoke -bytes, the game is up. You can index off of that
pointer as far into the data as you want. That means that -bytes has
to return a pointer to the beginning of the data, and it has to point
to a contiguous memory block until the end of the data.

If you want huge amounts of data in chunks, look at NSStream or any of
the other file handling APIs, which are numerous (but alas, not quite
so simple to use). Or switch to a 64-bit app, but that is ever so
slightly limiting right now.

Mike

Related mailsAuthorDate
mlNSData dataWithContentsOfMappedFile with huge files? Cameron Hayne Aug 25, 19:46
mlRe: NSData dataWithContentsOfMappedFile with huge files? Andrew Farmer Aug 25, 20:57
mlRe: NSData dataWithContentsOfMappedFile with huge files? Shawn Erickson Aug 25, 22:54
mlRe: NSData dataWithContentsOfMappedFile with huge files? Cameron Hayne Aug 27, 08:29
mlRe: Re: NSData dataWithContentsOfMappedFile with huge files? Michael Ash Aug 27, 14:48
mlRe: NSData dataWithContentsOfMappedFile with huge files? Robert Martin Aug 27, 21:21
mlRe: NSData dataWithContentsOfMappedFile with huge files? Cameron Hayne Aug 27, 23:45
mlRe: NSData dataWithContentsOfMappedFile with huge files? j o a r Aug 28, 02:29