heapy 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/check_changelog.yml +13 -0
  3. data/.gitignore +1 -0
  4. data/CHANGELOG.md +8 -0
  5. data/README.md +38 -4
  6. data/bin/heapy +1 -2
  7. data/heapy.gemspec +4 -4
  8. data/lib/heapy.rb +90 -55
  9. data/lib/heapy/analyzer.rb +15 -6
  10. data/lib/heapy/diff.rb +105 -0
  11. data/lib/heapy/version.rb +1 -1
  12. metadata +30 -35
  13. data/lib/heapy/alive.rb +0 -269
  14. data/scratch.rb +0 -64
  15. data/weird_memory/run.rb +0 -31
  16. data/weird_memory/singleton_class/singleton_class.rb +0 -26
  17. data/weird_memory/singleton_class/singleton_class_in_class.rb +0 -29
  18. data/weird_memory/singleton_class/singleton_class_in_proc.rb +0 -28
  19. data/weird_memory/singleton_class/singleton_class_method_in_proc.rb +0 -26
  20. data/weird_memory/singleton_class_instance_eval/singleton_class_instance_eval.rb +0 -27
  21. data/weird_memory/singleton_class_instance_eval/singleton_class_instance_eval_in_class.rb +0 -29
  22. data/weird_memory/singleton_class_instance_eval/singleton_class_instance_eval_in_proc.rb +0 -29
  23. data/weird_memory/singleton_class_instance_eval/singleton_class_instance_eval_method_in_proc.rb +0 -27
  24. data/weird_memory/string/string.rb +0 -25
  25. data/weird_memory/string/string_in_class.rb +0 -27
  26. data/weird_memory/string/string_in_proc.rb +0 -26
  27. data/weird_memory/string/string_method_in_proc.rb +0 -25
  28. data/weird_memory/times_map/times_map.rb +0 -28
  29. data/weird_memory/times_map/times_map_in_class.rb +0 -29
  30. data/weird_memory/times_map/times_map_in_proc.rb +0 -30
  31. data/weird_memory/times_map/times_map_method_in_proc.rb +0 -29
@@ -1,31 +0,0 @@
1
- arg = ARGV.shift
2
-
3
- @fail_count = 0
4
-
5
- require 'fileutils'
6
- FileUtils.mkdir_p("tmp")
7
-
8
- def run(file, fail_count: @fail_count)
9
- cmd = "bundle exec ruby #{file}"
10
- puts " $ #{ cmd }"
11
- result = `#{cmd}`
12
- @fail_count += 1 if result.match(/FAIL/)
13
- puts " " + result
14
- end
15
-
16
- if arg.nil? || arg.downcase == "all"
17
- puts "== Running all directories (#{`ruby -v`.strip})"
18
- Dir.glob("weird_memory/**/*.rb").each do |file|
19
- next if file == __FILE__
20
- run(file)
21
- end
22
- else
23
- puts "== Running examples in `#{arg}` directory (#{`ruby -v`.strip})"
24
-
25
- Dir.glob("weird_memory/#{arg}/**/*.rb").each do |file|
26
- run(file)
27
- end
28
- end
29
-
30
- puts
31
- puts "Total failed: #{@fail_count}"
@@ -1,26 +0,0 @@
1
- $LOAD_PATH.unshift(File.expand_path(File.join(__FILE__, "../../../lib")))
2
-
3
- require 'heapy'
4
-
5
- Heapy::Alive.start_object_trace!(heap_file: ENV.fetch('HEAP_FILE') { 'tmp/heap.json' })
6
-
7
- def run
8
- string = ""
9
- Heapy::Alive.trace_without_retain(string)
10
- string.singleton_class
11
- string
12
-
13
- return nil
14
- end
15
-
16
- run
17
-
18
- alive_count = Heapy::Alive.traced_objects.select {|tracer|
19
- tracer.object_retained?
20
- }.length
21
- # should return 0, no traced objects are returned
22
-
23
- expected = 0
24
- actual = alive_count
25
- result = expected == actual ? "PASS" : "FAIL"
26
- puts "#{result}: expected: #{expected}, actual: #{actual}"
@@ -1,29 +0,0 @@
1
- $LOAD_PATH.unshift(File.expand_path(File.join(__FILE__, "../../../lib")))
2
-
3
- require 'heapy'
4
-
5
- Heapy::Alive.start_object_trace!(heap_file: ENV.fetch('HEAP_FILE') { 'tmp/heap.json' })
6
-
7
- class Runner
8
-
9
- def run
10
- string = ""
11
- Heapy::Alive.trace_without_retain(string)
12
- string.singleton_class
13
- string
14
-
15
- return nil
16
- end
17
- end
18
-
19
- Runner.new.run
20
-
21
- alive_count = Heapy::Alive.traced_objects.select {|tracer|
22
- tracer.object_retained?
23
- }.length
24
- # should return 0, no traced objects are returned
25
-
26
- expected = 0
27
- actual = alive_count
28
- result = expected == actual ? "PASS" : "FAIL"
29
- puts "#{result}: expected: #{expected}, actual: #{actual}"
@@ -1,28 +0,0 @@
1
- $LOAD_PATH.unshift(File.expand_path(File.join(__FILE__, "../../../lib")))
2
-
3
- require 'heapy'
4
-
5
- Heapy::Alive.start_object_trace!(heap_file: ENV.fetch('HEAP_FILE') { 'tmp/heap.json' })
6
-
7
- def run
8
- -> {
9
- string = ""
10
- Heapy::Alive.trace_without_retain(string)
11
- string.singleton_class
12
- string
13
- }.call
14
-
15
- return nil
16
- end
17
-
18
- run
19
-
20
- alive_count = Heapy::Alive.traced_objects.select {|tracer|
21
- tracer.object_retained?
22
- }.length
23
- # should return 0, no traced objects are returned
24
-
25
- expected = 0
26
- actual = alive_count
27
- result = expected == actual ? "PASS" : "FAIL"
28
- puts "#{result}: expected: #{expected}, actual: #{actual}"
@@ -1,26 +0,0 @@
1
- $LOAD_PATH.unshift(File.expand_path(File.join(__FILE__, "../../../lib")))
2
-
3
- require 'heapy'
4
-
5
- Heapy::Alive.start_object_trace!(heap_file: ENV.fetch('HEAP_FILE') { 'tmp/heap.json' })
6
-
7
- def run
8
- string = ""
9
- Heapy::Alive.trace_without_retain(string)
10
- string.singleton_class
11
- string
12
-
13
- return nil
14
- end
15
-
16
- -> { run }.call
17
-
18
- alive_count = Heapy::Alive.traced_objects.select {|tracer|
19
- tracer.object_retained?
20
- }.length
21
- # should return 0, no traced objects are returned
22
-
23
- expected = 0
24
- actual = alive_count
25
- result = expected == actual ? "PASS" : "FAIL"
26
- puts "#{result}: expected: #{expected}, actual: #{actual}"
@@ -1,27 +0,0 @@
1
- $LOAD_PATH.unshift(File.expand_path(File.join(__FILE__, "../../../lib")))
2
-
3
- require 'heapy'
4
-
5
- Heapy::Alive.start_object_trace!(heap_file: ENV.fetch('HEAP_FILE') { 'tmp/heap.json' })
6
-
7
- def run
8
- string = ""
9
- Heapy::Alive.trace_without_retain(string)
10
- string.singleton_class.instance_eval do
11
- end
12
- string
13
-
14
- return nil
15
- end
16
-
17
- run
18
-
19
- alive_count = Heapy::Alive.traced_objects.select {|tracer|
20
- tracer.object_retained?
21
- }.length
22
- # should return 0, no traced objects are returned
23
-
24
- expected = 0
25
- actual = alive_count
26
- result = expected == actual ? "PASS" : "FAIL"
27
- puts "#{result}: expected: #{expected}, actual: #{actual}"
@@ -1,29 +0,0 @@
1
- $LOAD_PATH.unshift(File.expand_path(File.join(__FILE__, "../../../lib")))
2
-
3
- require 'heapy'
4
-
5
- Heapy::Alive.start_object_trace!(heap_file: ENV.fetch('HEAP_FILE') { 'tmp/heap.json' })
6
-
7
- class Runner
8
- def run
9
- string = ""
10
- Heapy::Alive.trace_without_retain(string)
11
- string.singleton_class.instance_eval do
12
- end
13
- string
14
-
15
- return nil
16
- end
17
- end
18
-
19
- Runner.new.run
20
-
21
- alive_count = Heapy::Alive.traced_objects.select {|tracer|
22
- tracer.object_retained?
23
- }.length
24
- # should return 0, no traced objects are returned
25
-
26
- expected = 0
27
- actual = alive_count
28
- result = expected == actual ? "PASS" : "FAIL"
29
- puts "#{result}: expected: #{expected}, actual: #{actual}"
@@ -1,29 +0,0 @@
1
- $LOAD_PATH.unshift(File.expand_path(File.join(__FILE__, "../../../lib")))
2
-
3
- require 'heapy'
4
-
5
- Heapy::Alive.start_object_trace!(heap_file: ENV.fetch('HEAP_FILE') { 'tmp/heap.json' })
6
-
7
- def run
8
- -> {
9
- string = ""
10
- Heapy::Alive.trace_without_retain(string)
11
- string.singleton_class.instance_eval do
12
- end
13
- string
14
- }.call
15
-
16
- return nil
17
- end
18
-
19
- run
20
-
21
- alive_count = Heapy::Alive.traced_objects.select {|tracer|
22
- tracer.object_retained?
23
- }.length
24
- # should return 0, no traced objects are returned
25
-
26
- expected = 0
27
- actual = alive_count
28
- result = expected == actual ? "PASS" : "FAIL"
29
- puts "#{result}: expected: #{expected}, actual: #{actual}"
@@ -1,27 +0,0 @@
1
- $LOAD_PATH.unshift(File.expand_path(File.join(__FILE__, "../../../lib")))
2
-
3
- require 'heapy'
4
-
5
- Heapy::Alive.start_object_trace!(heap_file: ENV.fetch('HEAP_FILE') { 'tmp/heap.json' })
6
-
7
- def run
8
- string = ""
9
- Heapy::Alive.trace_without_retain(string)
10
- string.singleton_class.instance_eval do
11
- end
12
- string
13
-
14
- return nil
15
- end
16
-
17
- -> { run }.call
18
-
19
- alive_count = Heapy::Alive.traced_objects.select {|tracer|
20
- tracer.object_retained?
21
- }.length
22
- # should return 0, no traced objects are returned
23
-
24
- expected = 0
25
- actual = alive_count
26
- result = expected == actual ? "PASS" : "FAIL"
27
- puts "#{result}: expected: #{expected}, actual: #{actual}"
@@ -1,25 +0,0 @@
1
- $LOAD_PATH.unshift(File.expand_path(File.join(__FILE__, "../../../lib")))
2
-
3
- require 'heapy'
4
-
5
- Heapy::Alive.start_object_trace!(heap_file: ENV.fetch('HEAP_FILE') { 'tmp/heap.json' })
6
-
7
- def run
8
- string = ""
9
- Heapy::Alive.trace_without_retain(string)
10
- string
11
-
12
- return nil
13
- end
14
-
15
- run
16
-
17
- alive_count = Heapy::Alive.traced_objects.select {|tracer|
18
- tracer.object_retained?
19
- }.length
20
- # should return 0, no traced objects are returned
21
-
22
- expected = 0
23
- actual = alive_count
24
- result = expected == actual ? "PASS" : "FAIL"
25
- puts "#{result}: expected: #{expected}, actual: #{actual}"
@@ -1,27 +0,0 @@
1
- $LOAD_PATH.unshift(File.expand_path(File.join(__FILE__, "../../../lib")))
2
-
3
- require 'heapy'
4
-
5
- Heapy::Alive.start_object_trace!(heap_file: ENV.fetch('HEAP_FILE') { 'tmp/heap.json' })
6
-
7
- class Runner
8
- def run
9
- string = ""
10
- Heapy::Alive.trace_without_retain(string)
11
- string
12
-
13
- return nil
14
- end
15
- end
16
-
17
- Runner.new.run
18
-
19
- alive_count = Heapy::Alive.traced_objects.select {|tracer|
20
- tracer.object_retained?
21
- }.length
22
- # should return 0, no traced objects are returned
23
-
24
- expected = 0
25
- actual = alive_count
26
- result = expected == actual ? "PASS" : "FAIL"
27
- puts "#{result}: expected: #{expected}, actual: #{actual}"
@@ -1,26 +0,0 @@
1
- $LOAD_PATH.unshift(File.expand_path(File.join(__FILE__, "../../../lib")))
2
-
3
- require 'heapy'
4
-
5
- Heapy::Alive.start_object_trace!(heap_file: ENV.fetch('HEAP_FILE') { 'tmp/heap.json' })
6
-
7
- def run
8
- -> {
9
- string = ""
10
- Heapy::Alive.trace_without_retain(string)
11
- string
12
- }.call
13
- return nil
14
- end
15
-
16
- run
17
-
18
- alive_count = Heapy::Alive.traced_objects.select {|tracer|
19
- tracer.object_retained?
20
- }.length
21
- # should return 0, no traced objects are returned
22
-
23
- expected = 0
24
- actual = alive_count
25
- result = expected == actual ? "PASS" : "FAIL"
26
- puts "#{result}: expected: #{expected}, actual: #{actual}"
@@ -1,25 +0,0 @@
1
- $LOAD_PATH.unshift(File.expand_path(File.join(__FILE__, "../../../lib")))
2
-
3
- require 'heapy'
4
-
5
- Heapy::Alive.start_object_trace!(heap_file: ENV.fetch('HEAP_FILE') { 'tmp/heap.json' })
6
-
7
- def run
8
- string = ""
9
- Heapy::Alive.trace_without_retain(string)
10
- string
11
-
12
- return nil
13
- end
14
-
15
- -> {run}.call
16
-
17
- alive_count = Heapy::Alive.traced_objects.select {|tracer|
18
- tracer.object_retained?
19
- }.length
20
- # should return 0, no traced objects are returned
21
-
22
- expected = 0
23
- actual = alive_count
24
- result = expected == actual ? "PASS" : "FAIL"
25
- puts "#{result}: expected: #{expected}, actual: #{actual}"
@@ -1,28 +0,0 @@
1
- $LOAD_PATH.unshift(File.expand_path(File.join(__FILE__, "../../../lib")))
2
-
3
- require 'heapy'
4
-
5
- Heapy::Alive.start_object_trace!(heap_file: ENV.fetch('HEAP_FILE') { 'tmp/heap.json' })
6
-
7
- def run
8
- array = 1.times.map {
9
- string = ""
10
- Heapy::Alive.trace_without_retain(string)
11
- string
12
- }
13
- array = nil
14
- return nil
15
- end
16
-
17
- run
18
-
19
-
20
- alive_count = Heapy::Alive.traced_objects.select {|tracer|
21
- tracer.object_retained?
22
- }.length
23
- # should return 0, no traced objects are returned
24
-
25
- expected = 0
26
- actual = alive_count
27
- result = expected == actual ? "PASS" : "FAIL"
28
- puts "#{result}: expected: #{expected}, actual: #{actual}"
@@ -1,29 +0,0 @@
1
- $LOAD_PATH.unshift(File.expand_path(File.join(__FILE__, "../../../lib")))
2
-
3
- require 'heapy'
4
-
5
- Heapy::Alive.start_object_trace!(heap_file: ENV.fetch('HEAP_FILE') { 'tmp/heap.json' })
6
-
7
- class Runner
8
- def run
9
- array = 1.times.map {
10
- string = ""
11
- Heapy::Alive.trace_without_retain(string)
12
- string
13
- }
14
- array = nil
15
- return nil
16
- end
17
- end
18
-
19
- Runner.new.run
20
-
21
- alive_count = Heapy::Alive.traced_objects.select {|tracer|
22
- tracer.object_retained?
23
- }.length
24
- # should return 0, no traced objects are returned
25
-
26
- expected = 0
27
- actual = alive_count
28
- result = expected == actual ? "PASS" : "FAIL"
29
- puts "#{result}: expected: #{expected}, actual: #{actual}"
@@ -1,30 +0,0 @@
1
- $LOAD_PATH.unshift(File.expand_path(File.join(__FILE__, "../../../lib")))
2
-
3
- require 'heapy'
4
-
5
- Heapy::Alive.start_object_trace!(heap_file: ENV.fetch('HEAP_FILE') { 'tmp/heap.json' })
6
-
7
- def run
8
- -> {
9
- array = 1.times.map {
10
- string = ""
11
- Heapy::Alive.trace_without_retain(string)
12
- string
13
- }
14
- array = nil
15
- }.call
16
-
17
- return nil
18
- end
19
-
20
- run
21
-
22
- alive_count = Heapy::Alive.traced_objects.select {|tracer|
23
- tracer.object_retained?
24
- }.length
25
- # should return 0, no traced objects are returned
26
-
27
- expected = 0
28
- actual = alive_count
29
- result = expected == actual ? "PASS" : "FAIL"
30
- puts "#{result}: expected: #{expected}, actual: #{actual}"