On 6/20/13 11:52 PM, Quincey Morris wrote:
OK, but isn't NSFileWrapper supposed to facilitate exactly that by providing
sub-wrappers instead of actual data of contained files/folders, which can be
read on demand when needed?

No, NSFileWrapper provides *lazy* loading, in the sense that you don't need to
load a file until/unless it's actually needed. It doesn't provide any mechanism
for evicting file contents from memory -- not that I can find, and I looked
hard. If you need to read all the files, they will all eventually be in memory.

Yes, but the important word is "eventually". It seems that the default implementation of UIDocument uses an NSFileWrapper initialized with the NSFileWrapperReadingImmediate reading option.

When I create a NSFileWrapper not using that option it works, meaning it now opens and loads the package document it previously crashed on. I wonder what surprises I will run into with lazy wrapper loading like that. Initial tests show no problems when changing the document and saving the whole thing. For now it seems to work exactly like on OSX.

What is interesting too is that my application was able to create the whole wrapper structure when it first created the package. It would have required the same amount of memory to hold the wrappers in memory before they get written to the disk by UIDocument. Maybe it has to do with the fact that it is creating the structure incrementally and relatively slowly while downloading objects over the network. Reading the UIDocument from disk on the other hand requires it to load everything instantly. Maybe there's some system safeguard in place that kills apps whose memory usage increases too rapidly.

This is doubly irritating, because if the file contents is an archive, or
otherwise needs to be converted or expanded, then both the raw data and
unarchived data are in memory.**

This is distinct from *incremental* loading, which loads the raw data in pieces
and only temporarily.  This cannot -- in practical way -- be done with 
NSFileWrapper.

While you can't have a filewrapper load one file incrementally, you sure can use NSFileWrapper to load the contents of a folder structure's files incrementally, one file at a time.

Regards
Markus
--
__________________________________________
Markus Spoettl
_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to