Sha256: 3453d3f82bc4702547b37286a62ffb432bac4f5277cb71c223f0096b4fd6ce32

Contents?: true

Size: 794 Bytes

Versions: 10

Compression:

Stored size: 794 Bytes

Contents

require 'map'

##
#
  gc =
    lambda do
      10.times{ GC.start }
    end

  leak =
    lambda do
      100.times do
        m = Map.new

        1000.times do |i|
          m[rand.to_s] = rand
        end
      end

      gc.call()
    end

##
#


  leak.call()
  before = Process.size


  leak.call()
  after = Process.size

  delta = [after.first - before.first, after.last - before.last]

  p :before => before 
  p :after => after 
  p :delta => delta


##
#
  BEGIN {

    module Process
      def self.size pid = Process.pid 
        stdout = `ps wwwux -p #{ pid }`.split(%r/\n/)
        vsize, rsize = stdout.last.split(%r/\s+/)[4,2].map{|i| i.to_i}
      end

      def self.vsize
        size.first.to_i
      end

      def self.rsize
        size.last.to_i
      end
    end

  }

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
map-5.1.0 test/leak.rb
map-4.7.1 test/leak.rb
map-4.7.0 test/leak.rb
map-4.6.1 test/leak.rb
map-4.6.0 test/leak.rb
map-4.5.1 test/leak.rb
map-4.5.0 test/leak.rb
map-4.4.0 test/leak.rb
map-4.3.0 test/leak.rb
map-4.2.0 test/leak.rb