On 29 Nov 08, at 14:23, Nick Zitzmann wrote:
On Nov 29, 2008, at 5:39 AM, Mudi Dandan wrote:
Is it possible to to display a memory mapped file in an NSTextView

Of course.

With one caveat: When creating a memory mapping (by using mmap), you have to specify the length of the region you want to map - so, if the file grows, you have to remap the file. Detecting this is up to you; kqueue may be useful in doing so. Also, if the file gets really large*, it may fail to map at all on 32-bit systems, as there's a limited amount of address space available.

Unless you're absolutely sure that memory-mapping files is crucial to your application's performance, try just using standard file descriptors first. The performance difference isn't that huge, and there are a lot fewer caveats** involved.

*: More than a gigabyte or two is definitely impossible, as there simply isn't that much contiguous address space available. You may get failures even earlier if the address space is sufficiently fragmented, which may be aggravated by mapping multiple files and/or remapping files as they grow.

**: For example, if a memory-mapped file is truncated while it's mapped, the program with the memory mapping will segfault (without warning) as soon as it tries to read any portion of the file that's been truncated. There is no way to avoid this, besides convincing everybody else to not truncate your memory-mapped files.
_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to