R
rickhg12hs
I don't understand some things about the garbage collector ... but I'd
like to.
$ ruby -w -e 'puts "Uncollected Bignums: %d" %
ObjectSpace.each_object(Bignum) {|i| p i}'
Uncollected Bignums: 0
Okay good - no Bignums hanging out.
$ ruby -w -e 'GC.start;puts "Uncollected Bignums: %d" %
ObjectSpace.each_object(Bignum) {|i| p i}'
Uncollected Bignums: 0
This is good too. GC doesn't instantiate Bignums.
$ ruby -w -e 'Integer("8"*50);puts "Uncollected Bignums: %d" %
ObjectSpace.each_object(Bignum) {|i| p i}'
88888888888888888888888888888888888888888888888888
Uncollected Bignums: 1
This seems reasonable - Bignum created and it shows up in ObjectSpace.
$ ruby -w -e 'a=Integer("8"*50);puts "Uncollected Bignums: %d" %
ObjectSpace.each_object(Bignum) {|i| p i}'
88888888888888888888888888888888888888888888888888
Uncollected Bignums: 1
This really makes sense - "a" needs to point to the Bignum.
$ ruby -w -e 'a=Integer("8"*50);GC.start;puts "Uncollected Bignums: %d"
% ObjectSpace.each_object(Bignum) {|i| p i}'
88888888888888888888888888888888888888888888888888
Uncollected Bignums: 1
Makes sense - can't throw away Bignum that "a" is referencing.
$ ruby -w -e 'Integer("8"*50);GC.start;puts "Uncollected Bignums: %d" %
ObjectSpace.each_object(Bignum) {|i| p i}'
88888888888888888888888888888888888888888888888888
Uncollected Bignums: 1
Hmmmm. Why is the Bignum still here?
$ ruby -w -e 'a=Integer("8"*50);a=nil;GC.start;puts "Uncollected
Bignums: %d" % ObjectSpace.each_object(Bignum) {|i| p i}'
88888888888888888888888888888888888888888888888888
Uncollected Bignums: 1
Same here. Why wasn't the Bignum garbage collected?
like to.
$ ruby -w -e 'puts "Uncollected Bignums: %d" %
ObjectSpace.each_object(Bignum) {|i| p i}'
Uncollected Bignums: 0
Okay good - no Bignums hanging out.
$ ruby -w -e 'GC.start;puts "Uncollected Bignums: %d" %
ObjectSpace.each_object(Bignum) {|i| p i}'
Uncollected Bignums: 0
This is good too. GC doesn't instantiate Bignums.
$ ruby -w -e 'Integer("8"*50);puts "Uncollected Bignums: %d" %
ObjectSpace.each_object(Bignum) {|i| p i}'
88888888888888888888888888888888888888888888888888
Uncollected Bignums: 1
This seems reasonable - Bignum created and it shows up in ObjectSpace.
$ ruby -w -e 'a=Integer("8"*50);puts "Uncollected Bignums: %d" %
ObjectSpace.each_object(Bignum) {|i| p i}'
88888888888888888888888888888888888888888888888888
Uncollected Bignums: 1
This really makes sense - "a" needs to point to the Bignum.
$ ruby -w -e 'a=Integer("8"*50);GC.start;puts "Uncollected Bignums: %d"
% ObjectSpace.each_object(Bignum) {|i| p i}'
88888888888888888888888888888888888888888888888888
Uncollected Bignums: 1
Makes sense - can't throw away Bignum that "a" is referencing.
$ ruby -w -e 'Integer("8"*50);GC.start;puts "Uncollected Bignums: %d" %
ObjectSpace.each_object(Bignum) {|i| p i}'
88888888888888888888888888888888888888888888888888
Uncollected Bignums: 1
Hmmmm. Why is the Bignum still here?
$ ruby -w -e 'a=Integer("8"*50);a=nil;GC.start;puts "Uncollected
Bignums: %d" % ObjectSpace.each_object(Bignum) {|i| p i}'
88888888888888888888888888888888888888888888888888
Uncollected Bignums: 1
Same here. Why wasn't the Bignum garbage collected?