From: Charles Oliver Nutter <headius@headius.com>
To: rack-devel@googlegroups.com
Subject: Re: Not cleaning up tempfiles for multipart?
Date: Sun, 7 Mar 2010 08:27:55 -0600 [thread overview]
Message-ID: <f04d2211003070627i79e7368fl98e7cd947eda156@mail.gmail.com> (raw)
In-Reply-To: <20100306075548.GB6474@dcvr.yhbt.net>
On Sat, Mar 6, 2010 at 1:55 AM, Eric Wong <normalperson@yhbt.net> wrote:
> Charles Oliver Nutter <headius@headius.com> wrote:
>> If I'm correct, this is a bug. Tempfiles should not be relied upon to
>> clean themselves up in response to GC, since you don't know when GC
>> will fire...
>
> Why not? Tempfiles are objects, too. It's perfectly reasonable
> to let GC clean them up like any other object.
>
>
> I don't know why RewindableInput is monkeying with Tempfile internals,
> though.
It's roundly considered by every programming language community in the
world to be *really* bad form to let GC clean up IO. There's tons of
reasons for this:
* GC may not run as soon as you like, causing you to hold IO resources
too long (and under heavy load, potentially use up all descriptors for
a process)
* On some systems, old objects get promoted to heaps that are only
rarely collected, resulting in them potentially never GCing (or only
GCing extremely rarely)
* There's no reason you *shouldn't* be able to close resources when
they're no longer used. In this case, close any files opened for a
give request once the request has been processed (async libraries
using those files should expect them to be closed and deal with that
accordingly).
Bug-finding tools for several languages flag this sort of behavior as
a high-priority bug. Languages like Go, C#, and Java have or are
adding features to help guarantee you never do this. It's pretty much
universally frowned upon.
When I tweeted about Rubyists leaving IO objects to be cleaned up or
closed by GC, *everyone* agreed that it's a bug in the code, and that
nobody should ever rely on GC to release File/IO resources.
What more can I say? :)
- Charlie
next prev parent reply other threads:[~2010-03-07 14:28 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-05 14:40 Not cleaning up tempfiles for multipart? Charles Oliver Nutter
2010-03-05 14:47 ` Charles Oliver Nutter
2010-03-05 14:48 ` Charles Oliver Nutter
2010-03-06 10:20 ` Hongli Lai
2010-03-07 14:25 ` Charles Oliver Nutter
2010-03-06 7:55 ` Eric Wong
2010-03-06 10:25 ` Hongli Lai
2010-03-07 14:34 ` Charles Oliver Nutter
2010-03-08 0:22 ` Eric Wong
2010-03-08 1:12 ` Eric Wong
2010-03-17 15:41 ` Charles Oliver Nutter
2010-03-18 9:54 ` Eric Wong
2014-01-06 22:45 ` Wojtek Kruszewski
2014-02-11 21:05 ` Eric Wong
2014-03-27 21:40 ` Lenny Marks
2010-03-07 23:53 ` Eric Wong
2010-03-08 11:26 ` Hongli Lai
2010-03-08 11:30 ` Hongli Lai
2010-03-08 14:33 ` Randy Fischer
2010-03-08 14:43 ` Charles Oliver Nutter
2010-03-08 14:49 ` James Tucker
2010-03-17 2:37 ` Eric Wong
2010-03-08 13:22 ` Charles Oliver Nutter
2010-03-08 14:42 ` James Tucker
2010-03-08 17:24 ` Hongli Lai
2010-03-09 7:43 ` Charles Oliver Nutter
2010-03-08 10:05 ` James Tucker
2010-03-07 14:27 ` Charles Oliver Nutter [this message]
2010-03-08 0:18 ` Eric Wong
2010-03-08 10:07 ` James Tucker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://groups.google.com/group/rack-devel
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f04d2211003070627i79e7368fl98e7cd947eda156@mail.gmail.com \
--to=rack-devel@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).