On Mon, Aug 31, 2009 at 9:03 AM, Konrad Hinsen <konrad.hin...@fastmail.net>wrote:
> > > In this particular case, there is no reason to worry: open() returns a > file object that is fed to the method read(), but after that method > returns, there is no more reference to the object, so it is garbage > collected. Upon destruction of the file object, Python closes the > file. All that is documented behaviour in Python, so it is safe to > rely on it. > > If I recall correctly (and correct me if I'm wrong), Python uses a reference counting garbage collector. Which means as soon as the reference to the object goes away, the object gets collected and the handle closed. Most JVMs use some form of mark & sweep algorithm, which means it may be some time before the object gets collected (and the resource freed). This is especially the case in a generational GC system, where long-lived objects get collected much less frequently. So, for long-running programs, it's possible to pile up uncollected resources to the point where you run out of the resource, simply because unused objects haven't been collected yet. Generally, when you open a file descriptor, you should always make sure it's gets closed when you're done with it. Brian --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---