Class: HeapProfiler::Dump
- Inherits:
-
Object
- Object
- HeapProfiler::Dump
show all
- Defined in:
- lib/heap_profiler/dump.rb
Defined Under Namespace
Classes: GlobalStats, Stats
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(path) ⇒ Dump
Returns a new instance of Dump.
48
49
50
|
# File 'lib/heap_profiler/dump.rb', line 48
def initialize(path)
@path = path
end
|
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
46
47
48
|
# File 'lib/heap_profiler/dump.rb', line 46
def path
@path
end
|
Class Method Details
.open(dir, name) ⇒ Object
41
42
43
|
# File 'lib/heap_profiler/dump.rb', line 41
def open(dir, name)
Dump.new(File.join(dir, "#{name}.heap"))
end
|
Instance Method Details
#diff(other, file) ⇒ Object
ObjectSpace.dump_all itself allocate objects.
Before 2.7 it will allocate one String per class to get its name. After 2.7, it only allocate a couple hashes, a file etc.
Either way we need to exclude them from the reports
58
59
60
61
62
|
# File 'lib/heap_profiler/dump.rb', line 58
def diff(other, file)
each_line_with_address do |line, address|
file << line unless other.index.include?(address)
end
end
|
#each_line_with_address ⇒ Object
80
81
82
83
84
85
86
87
|
# File 'lib/heap_profiler/dump.rb', line 80
def each_line_with_address
File.open(path).each_line do |line|
yield line, line.byteslice(14, 12).to_i(16)
end
end
|
#each_object(since: nil, &block) ⇒ Object
64
65
66
|
# File 'lib/heap_profiler/dump.rb', line 64
def each_object(since: nil, &block)
Parser.load_many(path, since: since, &block)
end
|
#exist? ⇒ Boolean
89
90
91
|
# File 'lib/heap_profiler/dump.rb', line 89
def exist?
File.exist?(@path)
end
|
#index ⇒ Object
76
77
78
|
# File 'lib/heap_profiler/dump.rb', line 76
def index
@index ||= Native.addresses_set(path)
end
|
#presence ⇒ Object
93
94
95
|
# File 'lib/heap_profiler/dump.rb', line 93
def presence
exist? ? self : nil
end
|
#size ⇒ Object
72
73
74
|
# File 'lib/heap_profiler/dump.rb', line 72
def size
@size ||= File.open(path).each_line.count
end
|
#stats ⇒ Object
68
69
70
|
# File 'lib/heap_profiler/dump.rb', line 68
def stats
@stats ||= GlobalStats.from(self)
end
|