Sha256: d7bdf2d533f2c5bb9ede78cb1e6b963400d6755ec1022e5f892268e80ace585d

Contents?: true

Size: 821 Bytes

Versions: 22

Compression:

Stored size: 821 Bytes

Contents

# -*- encoding : utf-8 -*-
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

22 entries across 22 versions & 2 rubygems

Version Path
map-6.6.0 test/leak.rb
asana2flowdock-1.0.0 vendor/bundle/ruby/1.9.1/gems/map-6.5.5/test/leak.rb
map-6.5.5 test/leak.rb
map-6.5.4 test/leak.rb
map-6.5.3 test/leak.rb
map-6.5.2 test/leak.rb
map-6.5.1 test/leak.rb
map-6.5.0 test/leak.rb
map-6.4.2 test/leak.rb
map-6.4.1 test/leak.rb
map-6.4.0 test/leak.rb
map-6.3.0 test/leak.rb
map-6.2.0 test/leak.rb
map-6.1.0 test/leak.rb
map-6.0.1 test/leak.rb
map-6.0.0 test/leak.rb
map-5.8.0 test/leak.rb
map-5.6.1 test/leak.rb
map-5.5.0 test/leak.rb
map-5.4.0 test/leak.rb