> On 11 Feb 2016, at 20:44, Dan Lau <d...@twitter.com> wrote:
> 
> If a file has its contents mapped using NSData's
> initWithContentsOfFile + NSDataReadingMappedIfSafe,
> deleting it doesn't appear to affect reading it's mapped contents. Does
> anyone know if NSData uses mmap(2) under the hood to ensure that this sort
> of operation is valid?

[As Jens said: yes]

In fact, file data will stick around as long as you have an open file 
descriptor or a mapping.

A neat trick for temporary files that you want to make sure get cleaned up is 
to open() and unlink() immediately afterward.

The file data will be automatically deleted when your process exits.

Marcel


_______________________________________________

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