On 8/7/06, Sam Kong <sam.s.kong / gmail.com> wrote:
> Gregory Brown wrote:
> > On 8/7/06, Eric Hodel <drbrain / segment7.net> wrote:
> >
> >> IIRC an Integer's instance variables are eternal due to various
> >> implementation details.
> >
> > Specifically due to the fact that integers are immediate values in ruby.
> > (Thus, are never collected)
>
> Thank you for the answer.
> This is good news for my purpose.
> However, that creates another worry.
>
> (1..100000).each {|i|...}

Looks like in this case, they are garbage collected?

at startup
bash-3.1$ pmap 7764 | grep "total"
 total     4560K

after each
bash-3.1$ pmap 7764 | grep "total"
 total     4560K

> Now there are 100000 integers in the memory which won't die.
> Is it okay?

but after adding an accessor for x, and setting it to true:
(1..100000).each { |i| i.x = true }

bash-3.1$ pmap 7764 | grep "total"
 total    16308K

Big increase, but still not *that* bad.