From: cast_ent@... (Jeff) Date: 2004-02-19T01:09:53+09:00 Subject: Weird GC behaviour or memory leak with NArray::to_na? I have what appears to be a memory leak in my code, and I'm able to reproduce it using the following test code: require 'narray' a=Array.new(100,2) 200000.times{|x| #c=a.collect{|b| b+1} #This is OK. #a.collect!{|b| b+1} #This is OK. #a=a.collect{|b| b+1} #This is OK. #c=Array(a) #This is OK. d=NArray.to_na(a) #This results in huge memory bloat } Running this code shows my memory footprint increase monotonically from ~2M to >20M... I killed the process at this point. Any of the other commented lines would run with a stable memory footprint. However, if I add ObjectSpace::garbage_collect into the loop, everything is fine. Now to complicate matters further: require 'narray' a=Array.new(100,2) 200000.times{|x| d=a.collect{|b| NArray.to_na([b,b])} #memory bloat despite explicit GC! ObjectSpace::garbage_collect } This exhibits the growing memory footprint problem...... Help? Note: I realize this example may be a little contrived, but my code does this plus some more, requiring (IMHO) this approach. Can someone explain this behaviour? I use the .to_na constructor a lot in my code, and really need to sort this out, otherwise I cannot run my code for longer than brief periods before my system comes crashing on down. Thanks, Jeff