memory 0.3.0 → 0.4.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
- checksums.yaml.gz.sig +0 -0
- data/lib/memory/report.rb +9 -1
- data/lib/memory/sampler.rb +6 -0
- data/lib/memory/version.rb +1 -1
- data/lib/memory.rb +9 -2
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d560993f9f0c1142d7330fd7f17893d84c46a9d1a265150d5aa6bbc891175479
|
4
|
+
data.tar.gz: bef207c3e7221996f9ac5a1caf9c025fa8da025ea47b8ac222933cc5c08f1947
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 374e9de16464bcdc38453215dc0627d24651bb620f265453d37819e0faf6caef90be86f9ce772f70277a3aba4b4ec990d5587848c8964d17dd385359814081dc
|
7
|
+
data.tar.gz: 4e86fe73db538a6ce6e6b21d8a1bf57f32da62d1c5b7077c6aff8ca1593706ee787c2102bc9a141cce9b4d177415e015f7570e076218ee29b374f32b18a919ad
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/memory/report.rb
CHANGED
@@ -26,7 +26,15 @@ module Memory
|
|
26
26
|
end
|
27
27
|
|
28
28
|
attr :total_allocated
|
29
|
+
attr :total_retained
|
30
|
+
attr :aggregates
|
29
31
|
|
32
|
+
# Add all samples from the given sampler to this report.
|
33
|
+
def add(sampler)
|
34
|
+
self.concat(sampler.allocated)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Add allocations to this report.
|
30
38
|
def concat(allocations)
|
31
39
|
allocations.each do |allocation|
|
32
40
|
@total_allocated << allocation
|
@@ -37,7 +45,7 @@ module Memory
|
|
37
45
|
end
|
38
46
|
end
|
39
47
|
end
|
40
|
-
|
48
|
+
|
41
49
|
def print(io = $stderr)
|
42
50
|
io.puts "\# Memory Profile", nil
|
43
51
|
|
data/lib/memory/sampler.rb
CHANGED
@@ -75,6 +75,9 @@ module Memory
|
|
75
75
|
|
76
76
|
def start
|
77
77
|
GC.disable
|
78
|
+
3.times{GC.start}
|
79
|
+
|
80
|
+
# Ensure any allocations related to the block are freed:
|
78
81
|
GC.start
|
79
82
|
|
80
83
|
@generation = GC.count
|
@@ -90,6 +93,9 @@ module Memory
|
|
90
93
|
GC.enable
|
91
94
|
3.times{GC.start}
|
92
95
|
|
96
|
+
# See above.
|
97
|
+
GC.start
|
98
|
+
|
93
99
|
ObjectSpace.each_object do |object|
|
94
100
|
next unless ObjectSpace.allocation_generation(object) == @generation
|
95
101
|
|
data/lib/memory/version.rb
CHANGED
data/lib/memory.rb
CHANGED
@@ -13,10 +13,17 @@ require_relative "memory/report"
|
|
13
13
|
require_relative "memory/sampler"
|
14
14
|
|
15
15
|
module Memory
|
16
|
-
def self.report
|
16
|
+
def self.capture(report = nil, &block)
|
17
17
|
sampler = Sampler.new
|
18
18
|
sampler.run(&block)
|
19
19
|
|
20
|
-
|
20
|
+
report ||= Report.general
|
21
|
+
report.add(sampler)
|
22
|
+
|
23
|
+
return report
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.report(&block)
|
27
|
+
self.capture(&block)
|
21
28
|
end
|
22
29
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|