• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Deleting an file that's been NSData memory mapped - safe?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Deleting an file that's been NSData memory mapped - safe?


  • Subject: Re: Deleting an file that's been NSData memory mapped - safe?
  • From: email@hidden
  • Date: Sun, 14 Feb 2016 20:45:25 +0900



> On Feb 14, 2016, at 7:17 PM, Marcel Weiher <email@hidden> wrote:
>
>
>> On 11 Feb 2016, at 20:44, Dan Lau <email@hidden> 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
>
>
> _______________________________________________
>
> /
Would the file itself be accessible by another process before your process exits?
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Deleting an file that's been NSData memory mapped - safe?
      • From: Chris Ridd <email@hidden>
References: 
 >Deleting an file that's been NSData memory mapped - safe? (From: Dan Lau <email@hidden>)
 >Re: Deleting an file that's been NSData memory mapped - safe? (From: Marcel Weiher <email@hidden>)

  • Prev by Date: Re: Deleting an file that's been NSData memory mapped - safe?
  • Next by Date: Re: Deleting an file that's been NSData memory mapped - safe?
  • Previous by thread: Re: Deleting an file that's been NSData memory mapped - safe?
  • Next by thread: Re: Deleting an file that's been NSData memory mapped - safe?
  • Index(es):
    • Date
    • Thread