2009/10/30 Haoqi Haoqi <axgle / 126.com>:
> irb:
> name='1'*1024*1024*100;nil # 100m
> name=rand
> GC.start
> =============
> $ ps -ef|grep irb
> ax 14081 13958  14:57 pts/2 0:00:00 irb
>
> $ top 14081
> =============
> 14081 ax 0 0 14m 112m 1960 S  11.3 0:00.66 irb
> 14081 ax 0 0 13824 1m 1960 S  .2 0:00.54 irb
> -------------
> when "name=rand;GC.start", 112m->11m,why?

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.

Cheers

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/