# Re: IO not closed by GC

**URL:** <https://www.ruby-forum.com/t/re-io-not-closed-by-gc/94004>\
**Category:** Ruby\
**Created:** [April 17, 2006, 10:09pm UTC](https://www.ruby-forum.com/t/re-io-not-closed-by-gc/94004 "2006-04-17T22:09:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gennady\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c57346/32.png) [@Gennady\_B](https://www.ruby-forum.com/u/Gennady_B)\
**Post date:** [April 17, 2006, 10:09pm UTC](https://www.ruby-forum.com/t/re-io-not-closed-by-gc/94004/1 "2006-04-17T22:09:35Z")

</div>

Hi, Giles

I must relunctantly admit that I did not get your question. Are you  
asking about GC in general or how GC.start operates in particular?  
Assuming the latter, here’s my rather naïve take on it.

Garbage collection is pretty complex facility that works deep inside a  
VM or an interpreter, governed by its own rules and conditions. So from  
where you call GC.start it may not even be possible at all to invoke all  
needed machinery. Rather it is like saying to the VM/interprepter: start  
garbage collection at you EARLIEST convenience, screw everything  
regarding optimization and any other considerations. This “screw” part  
is why it is usually a bad practice to causually intrude into GC realm,  
as it may drastically affect the performance.

However, sometimes it may be good to have some communication path  
between your script and GC. I remember using GC.start after some memory  
intensive operations are ended when I kind of expect that it will be  
quiet for some time, thus a good opportunity for GC to cleanup. Also, I  
used it in some test cases in teardown().

Gennady.

---

<div class="post-metadata">

**Author:** ![Gennady\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c57346/32.png) [@Gennady\_B](https://www.ruby-forum.com/u/Gennady_B)\
**Post date:** [April 17, 2006, 10:28pm UTC](https://www.ruby-forum.com/t/re-io-not-closed-by-gc/94004/2 "2006-04-17T22:28:20Z")

</div>

Hi Gennady, sorry, it was a bit wandering. What I mean is, why even  
bother? The statement isn’t actually guaranteed to do anything, and  
even if it does do something, it usually isn’t a good thing to do.  
Usually, though, when I see something in a language and I can’t see  
the point, there’s often some uber-hacker trick I’ve never encountered  
that makes the thing staggeringly useful in a small number of special  
cases.

Giles

---

<div class="post-metadata">

**Author:** ![Gennady\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c57346/32.png) [@Gennady\_B](https://www.ruby-forum.com/u/Gennady_B)\
**Post date:** [April 18, 2006, 6:59pm UTC](https://www.ruby-forum.com/t/re-io-not-closed-by-gc/94004/3 "2006-04-18T18:59:20Z")

</div>

2006/4/17, Giles B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Hi Gennady, sorry, it was a bit wandering. What I mean is, why even  
> bother? The statement isn’t actually guaranteed to do anything, and  
> even if it does do something, it usually isn’t a good thing to do.  
> Usually, though, when I see something in a language and I can’t see  
> the point, there’s often some uber-hacker trick I’ve never encountered  
> that makes the thing staggeringly useful in a small number of special  
> cases.

Honestly, to me it’s even more unclear what you’re after. I suggest  
you start over with a new thread formulating your question again. That  
way you might also reach more people so your chances of getting a  
proper answer are higher. 🙂

Kind regards

robert
