[Borges-users] memory strikes back!

Michael Neumann mneumann at ntecs.de
Mon May 10 13:32:28 EDT 2004


On Mon, May 10, 2004 at 08:36:08PM +0400, ??????? ???????? wrote:
> Hi,
> 
> about the ol' Borges memory problem: there's a small but nonzero 
> possibility that continuations+objects+weakrefs are a bad combination 
> in Ruby, after all. Here's a small test I just wrote. I let it grow to 
> about 70 megs on my system before shutting it down... although it's 
> obvious from the code that memory should be bounded.

I am not 100% sure, but delete_if could be the problem. 
See the following script:


  N = 10_000_000
  a = []

  N.times {
    a << 1
  }

  puts "mem after #{N} records"
  sleep 3

  a.delete_if {|x| x == 1}
  #a = a.reject {|x| x == 1}
  p a.size
  GC.start

  puts "mem after delete_if"
  sleep 3


On my system, it grows up to 129 MB of memory after constructing the
array, but stays the same size after the delete_if. If you comment the
delete_if line and uncomment the following line instead (reject), it
will lower it's memory usage after GC.start to 44 MB. 

But using reject instead of delete_if does not solve the problem. Memory
still grows infinitively.

Regards,

  Michael


More information about the Borges-users mailing list