leak_profiler 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/leak_profiler/allocations.rb +16 -2
- data/sig/generated/leak_profiler/allocations.rbs +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0893023e2e636f17ea493dbb9e48a3663efdec4839aa0f8f92575fbf679d619f'
|
4
|
+
data.tar.gz: 5274e289f44e7d0157c337f44b02d8e7628b482d1c3033e22eee8d5a0b3addac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 565d9b09913c43416dce885ce9345e2d2d41a383c35d3238ff3d06609809da29b5e534ffaf6485069c850a9c7f9780f5a6b0221ec81345eb3d88724327bc0134
|
7
|
+
data.tar.gz: 762cc7effc4e9d7f0780fa193a60f6f977de4169d7a709d42cb5191e5fe88cc2be78b09603c0815a11774ff07b6888f8a5e75543f719a472cc3929f6ef7cfca7
|
@@ -22,13 +22,16 @@ class LeakProfiler
|
|
22
22
|
def report
|
23
23
|
@thread = Thread.start do
|
24
24
|
loop do
|
25
|
-
allocations = {}
|
26
|
-
|
27
25
|
ObjectSpace.trace_object_allocations_start
|
28
26
|
sleep(@interval)
|
29
27
|
ObjectSpace.trace_object_allocations_stop
|
30
28
|
|
29
|
+
allocations = {}
|
30
|
+
allocations_by_class = Hash.new { |h, k| h[k] = 0 }
|
31
|
+
|
31
32
|
ObjectSpace.each_object.each do |obj|
|
33
|
+
allocations_by_class[obj.class] += ObjectSpace.memsize_of(obj)
|
34
|
+
|
32
35
|
key = allocated_location(obj)
|
33
36
|
next unless key
|
34
37
|
|
@@ -40,6 +43,7 @@ class LeakProfiler
|
|
40
43
|
allocations[key][:sample_object] = obj
|
41
44
|
end
|
42
45
|
|
46
|
+
report_allocations_class(allocations_by_class)
|
43
47
|
report_allocations(allocations)
|
44
48
|
report_referrer_objects(allocations)
|
45
49
|
end
|
@@ -48,6 +52,16 @@ class LeakProfiler
|
|
48
52
|
|
49
53
|
private
|
50
54
|
|
55
|
+
def report_allocations_class(allocations_by_class)
|
56
|
+
return if @max_allocations <= 0
|
57
|
+
|
58
|
+
@logger.add(Logger::Severity::INFO, "Allocations by class #{"~" * 80}")
|
59
|
+
allocations_by_class.sort_by { |_, v| -v }
|
60
|
+
.take(@max_allocations).each do |klass, value|
|
61
|
+
@logger.add(Logger::Severity::INFO, "#{klass} retains #{value} bytes")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
51
65
|
def report_allocations(allocations)
|
52
66
|
return if @max_allocations <= 0
|
53
67
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leak_profiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Watson
|
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: '0'
|
73
73
|
requirements: []
|
74
|
-
rubygems_version: 3.6.
|
74
|
+
rubygems_version: 3.6.9
|
75
75
|
specification_version: 4
|
76
76
|
summary: A simple profiler for Ruby to detect memory leak.
|
77
77
|
test_files: []
|