From: Eric Wong Date: 2010-05-15T07:49:10+09:00 Subject: Re: Tempfile broken in Ruby 1.9.1? Robert Poor wrote: > I've been using Tempfile to create ~ 6 files of plot data. However, > all but the last two files were unlinked as the new ones were created, > so at the end, I only had two files, not six. I tried several > combinations - closing the file and re-opening in "r+" mode, NOT > closing the file -- nothing made a difference. > > I'm pretty sure the Tempfile contract is that the files are to stick > around until the process exits, but my Ruby process was no exiting. Hi Robert, No, the contract is that Tempfiles exist until there are no longer references to the objects that refer to them. Once there are no more references, the GC can reap and delete them when the finalizers are called. > I saw ruby-core discussions about a possible Tempfile bug in 1.9.1, > but that appeared to only apply when calling unlink(). > > So: Is this a known problem? > > * If so, I can work around it. Just keep references around to the tempfiles until you no longer need them. -- Eric Wong