File: proc.rb

package info (click to toggle)
ruby-heapy 0.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 97,184 kB
  • sloc: ruby: 394; makefile: 4
file content (28 lines) | stat: -rw-r--r-- 504 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
$LOAD_PATH.unshift(File.expand_path(File.join(__FILE__, "../../../../lib")))


require 'heapy'

Heapy::Alive.start_object_trace!(heap_file: ENV.fetch('HEAP_FILE'))

class Foo
end

def run
  thing = 3.times.map {
    foo = Foo.new
    Heapy::Alive.trace_without_retain(foo)
    foo
  }
  nil
end

run

alive_count = Heapy::Alive.traced_objects.select {|tracer|
  puts tracer.inspect
  tracer.object_retained?
}.length
# should return 0, no traced objects are returned

puts "Heapy output: #{alive_count}"