Because the large string is eligible for collection.
but “name=nil;GC.start”,dont work
What do you mean? If “name=nil” does not work you should probably
recompile your Ruby interpreter from the sources.
If you mean that you then do not observe a memory drop the reason is
that although the large string is eligible for collection there is no
guarantee when it will be collected. That’s how automatic GC works -
and is supposed to work.
If you mean that you then do not observe a memory drop the reason is
that although the large string is eligible for collection there is no
guarantee when it will be collected. That’s how automatic GC works -
and is supposed to work.
Cheers
robert
“name=nil;GC.start” dont work:
I mean that then do not observe a memory drop.
And “name=‘1’*1;GC.start” it also works(observer a memory drop)
irb:
name='1’10241024*100;nil # 100m
name=rand
GC.start
…
when “name=rand;GC.start”, 112m->11m,why?
but “name=nil;GC.start”,dont work
GC is tricky, because depending on what method calls, “ghost” references
to the original name might still exist on the stack.
You could try it with jruby/REE/1.9 to see if one of them works better,
but in this instance it appears that running “some methods” clears the
stack while others leave it dirty.
-r
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.