Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie Q:Considerations/Techniques for Saving Large Amounts of Data



My question is this, without implementing a database, how can I write
large data files to disk efficiently? Read below for more details.

I have a few applications which need to save thousands of objects in
arrays. What's more, is that each time the user uses the program they
will likely add more objects to different arrays, making the data
structure larger and larger and thus writing the file to disk will take
longer and longer.

I have noticed that iCal saves events as soon as the user creates them,
to a .ics file, but you never notice it saving. Maybe they have another
thread do the saving, or maybe there is a way to just re-write part of
the file?

Any thoughts, help or tips are most welcome.

You could try memory-mapped files. Basically the OS treats a disk file as if it were main memory, taking care of reading, writing and buffering the data. OS X has the UNIX function mmap (C API) which does this, and NSData has a dataWithContentsOfMappedFile: method. There are some caveats, mainly that the data should be self-contained, and the memory layout should be identical to the disk layout (otherwise there is no advantage). I don't think you can simply stuff ObjC objects with efficiency into a memory-mapped file.

Cheers, Glen Low


---
pixelglow software | simply brilliant stuff
www.pixelglow.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Newbie Q:Considerations/Techniques for Saving Large Amounts of Data (From: "Ian G. Gillespie" <email@hidden>)
 >Re: Newbie Q:Considerations/Techniques for Saving Large Amounts of Data (From: Philip Mötteli <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.