Re: Problem opening large files into NSDocument
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 (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Problem opening large files into NSDocument
Is your application 32-bit? Are you trying to load the entire file into memory if you are? If so that would be why you are getting that error. -- David Duncan On Jun 9, 2010, at 12:56 PM, Pascal Harris <45rpmli...@googlemail.com> wrote: > Weird one this - especially since I can't find any documentation which covers > it. > > 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? > > Thanks for any help you can provide - even just a link to a document that I > may have overlooked.___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > http://lists.apple.com/mailman/options/cocoa-dev/david.duncan%40apple.com > > This email sent to david.dun...@apple.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Problem opening large files into NSDocument
Weird one this - especially since I can't find any documentation which covers it. 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? Thanks for any help you can provide - even just a link to a document that I may have overlooked.___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com