From: Eric Sven Ristad Date: 2001-03-05T10:17:55+09:00 Subject: [ruby-talk:11986] possible memory leak in GDBM/gdbm The following program suggests there is a small memory leak in GDBM.[]=/gdbm_store and a massive memory leak in GDMB.[]/gdbm_fetch. I don't know if the memory leak is in the Ruby GDBM module (shipped with release 1.6.2) or in the underlying GDMB code (version 1.8.0 Alpha/OSF4.0d). Any suggestions/patches would be appreciated, Thanks, Eric require "gdbm" class Leak def initialize @disk = GDBM.open("/tmp/leaktest", 0600) @disk.clear @disk.reorganize @listing = [] Dir.foreach("/usr/bin") do |fn| path = "/usr/bin/" + fn if (test(?f, path) and test(?r, path)) then @listing << path end end end # write to local disk def in @disk.clear @disk.reorganize # load disk @listing.each{|path| open(path){|stream| @disk[path] = stream.read } } nil end # read from local disk def out @listing.each{|path| @disk[path]} nil end end =begin irb> load "leak.rb" irb> L=Leak.new 15.9M irb> L.in 33.0M irb> 10.times{L.in} 37.8M irb> 10.times{L.in} 38.8M irb> L.out 115M irb> 10.times{L.out} 980M =end