• 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: Problem opening large files into NSDocument
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem opening large files into NSDocument


  • Subject: Re: Problem opening large files into NSDocument
  • From: Jens Alfke <email@hidden>
  • Date: Wed, 9 Jun 2010 13:30:57 -0700

On Jun 9, 2010, at 12:56 PM, Pascal Harris wrote:

> I'm trying open a (very) large file (4GB) into an NSDocument.  Small files open file.  The monster fails with the error: "The document "test.pst" could not be opened.  The file is too large."  What gives - and how do I overcome it?  What is the maximum size that I can open using NSDocument?

NSDocument has at least three different methods you can override to get the file contents. You’re using the simplest one, that hands you the entire contents of the file in an NSData. This doesn’t scale well to huge files. You want to override one of the alternative methods where you get handed the path or URL of the file — then you can read the data yourself however you want.

Just keep in mind that in a 32-bit process you only have about 3GB of available address space (regardless of how much physical RAM the computer has.) And that address space gets fragmented as other memory blocks are allocated and freed, so generally the largest contiguous block that can be allocated is a lot smaller.

If possible you should stream the file contents using an NSFileHandle or lower-level I/O calls like fopen/fread/fclose. If you absolutely have to read an entire huge file into an NSData, you’ll get much better performance if you memory-map it (using the NSMappedRead option.)

—Jens_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Problem opening large files into NSDocument (From: Pascal Harris <email@hidden>)

  • Prev by Date: Adding objects from one array to another and and Key Value Observing
  • Next by Date: Re: KVO oddity (or am I *really* idiot ?)
  • Previous by thread: Re: Problem opening large files into NSDocument
  • Next by thread: Question about scaling text within a subView
  • Index(es):
    • Date
    • Thread