memory-leak 0.5.2 → 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
- checksums.yaml.gz.sig +0 -0
- data/lib/memory/leak/cluster.rb +6 -4
- data/lib/memory/leak/monitor.rb +15 -3
- data/lib/memory/leak/version.rb +1 -1
- data/readme.md +10 -0
- data/releases.md +10 -0
- data.tar.gz.sig +0 -0
- metadata +4 -4
- 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: 6ab8d8ab5e5ebff81f2847704ece1e34c20c71aa35a361caea8eafccc4b39f6f
|
|
4
|
+
data.tar.gz: e0a1dce4599132dc7a5aff55d1d639efb50e4d5f2b7c7f0f81289100471c8682
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cff70665edfcdf6d0e3d6ed7510586deb57fbd04f16476e5795acb73635688dec1f455a343b7bd3ba595a1e00a84dd65a34b658fecb11ad0b9fb2ff093e174e5
|
|
7
|
+
data.tar.gz: 9a09bb3be13452c240289f6d5433fc11c46213d987ac2abea1db6f6c2484f8453670413d9a48555e57d9cbbbd0918d91049ebb4d05306f74fa683efd8e839829
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/lib/memory/leak/cluster.rb
CHANGED
|
@@ -87,7 +87,7 @@ module Memory
|
|
|
87
87
|
def sample!
|
|
88
88
|
System.memory_usages(@processes.keys) do |process_id, memory_usage|
|
|
89
89
|
if monitor = @processes[process_id]
|
|
90
|
-
monitor.
|
|
90
|
+
monitor.sample!(memory_usage)
|
|
91
91
|
end
|
|
92
92
|
end
|
|
93
93
|
end
|
|
@@ -96,8 +96,6 @@ module Memory
|
|
|
96
96
|
#
|
|
97
97
|
# @yields {|process_id, monitor| ...} each process ID and monitor that is leaking or exceeds the memory limit.
|
|
98
98
|
def check!(&block)
|
|
99
|
-
return to_enum(__method__) unless block_given?
|
|
100
|
-
|
|
101
99
|
self.sample!
|
|
102
100
|
|
|
103
101
|
leaking = []
|
|
@@ -110,10 +108,14 @@ module Memory
|
|
|
110
108
|
end
|
|
111
109
|
end
|
|
112
110
|
|
|
113
|
-
|
|
111
|
+
if block_given?
|
|
112
|
+
leaking.each(&block)
|
|
113
|
+
end
|
|
114
114
|
|
|
115
115
|
# Finally, apply any per-cluster memory limits:
|
|
116
116
|
apply_limit!(@total_size_limit, &block) if @total_size_limit
|
|
117
|
+
|
|
118
|
+
return leaking
|
|
117
119
|
end
|
|
118
120
|
end
|
|
119
121
|
end
|
data/lib/memory/leak/monitor.rb
CHANGED
|
@@ -33,9 +33,11 @@ module Memory
|
|
|
33
33
|
def initialize(process_id = Process.pid, maximum_size: nil, maximum_size_limit: nil, threshold_size: DEFAULT_THRESHOLD_SIZE, increase_limit: DEFAULT_INCREASE_LIMIT)
|
|
34
34
|
@process_id = process_id
|
|
35
35
|
|
|
36
|
+
@sample_count = 0
|
|
36
37
|
@current_size = nil
|
|
37
38
|
@maximum_size = maximum_size
|
|
38
39
|
@maximum_size_limit = maximum_size_limit
|
|
40
|
+
@maximum_observed_size = nil
|
|
39
41
|
|
|
40
42
|
@threshold_size = threshold_size
|
|
41
43
|
@increase_count = 0
|
|
@@ -46,6 +48,7 @@ module Memory
|
|
|
46
48
|
def as_json(...)
|
|
47
49
|
{
|
|
48
50
|
process_id: @process_id,
|
|
51
|
+
sample_count: @sample_count,
|
|
49
52
|
current_size: @current_size,
|
|
50
53
|
maximum_size: @maximum_size,
|
|
51
54
|
maximum_size_limit: @maximum_size_limit,
|
|
@@ -83,6 +86,9 @@ module Memory
|
|
|
83
86
|
System.memory_usage(@process_id)
|
|
84
87
|
end
|
|
85
88
|
|
|
89
|
+
# @attribute [Integer] The number of samples taken.
|
|
90
|
+
attr :sample_count
|
|
91
|
+
|
|
86
92
|
# @returns [Integer] The last sampled memory usage.
|
|
87
93
|
def current_size
|
|
88
94
|
@current_size ||= memory_usage
|
|
@@ -99,14 +105,18 @@ module Memory
|
|
|
99
105
|
#
|
|
100
106
|
# @returns [Boolean] True if a memory leak has been detected.
|
|
101
107
|
def increase_limit_exceeded?
|
|
102
|
-
|
|
108
|
+
if @increase_limit
|
|
109
|
+
@increase_count >= @increase_limit
|
|
110
|
+
end
|
|
103
111
|
end
|
|
104
112
|
|
|
105
113
|
# Indicates that the current memory usage has grown beyond the maximum size limit.
|
|
106
114
|
#
|
|
107
115
|
# @returns [Boolean] True if the current memory usage has grown beyond the maximum size limit.
|
|
108
116
|
def maximum_size_limit_exceeded?
|
|
109
|
-
|
|
117
|
+
if @maximum_size_limit
|
|
118
|
+
self.current_size > @maximum_size_limit
|
|
119
|
+
end
|
|
110
120
|
end
|
|
111
121
|
|
|
112
122
|
# Indicates whether a memory leak has been detected.
|
|
@@ -119,7 +129,9 @@ module Memory
|
|
|
119
129
|
# Capture a memory usage sample and yield if a memory leak is detected.
|
|
120
130
|
#
|
|
121
131
|
# @yields {|sample, monitor| ...} If a memory leak is detected.
|
|
122
|
-
def sample!
|
|
132
|
+
def sample!(memory_usage = self.memory_usage)
|
|
133
|
+
@sample_count += 1
|
|
134
|
+
|
|
123
135
|
self.current_size = memory_usage
|
|
124
136
|
|
|
125
137
|
if @maximum_observed_size
|
data/lib/memory/leak/version.rb
CHANGED
data/readme.md
CHANGED
|
@@ -12,6 +12,16 @@ Please see the [project documentation](https://socketry.github.io/memory-leak/)
|
|
|
12
12
|
|
|
13
13
|
Please see the [project releases](https://socketry.github.io/memory-leak/releases/index) for all releases.
|
|
14
14
|
|
|
15
|
+
### v0.7.0
|
|
16
|
+
|
|
17
|
+
- Make both `increase_limit` and `maximum_size_limit` optional (if `nil`).
|
|
18
|
+
|
|
19
|
+
### v0.6.0
|
|
20
|
+
|
|
21
|
+
- Added `sample_count` attribute to monitor to track number of samples taken.
|
|
22
|
+
- `check!` method in cluster now returns an array of leaking monitors if no block is given.
|
|
23
|
+
- `Cluster#check!` now invokes `Monitor#sample!` to ensure memory usage is updated before checking for leaks.
|
|
24
|
+
|
|
15
25
|
### v0.5.0
|
|
16
26
|
|
|
17
27
|
- Improved variable names.
|
data/releases.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Releases
|
|
2
2
|
|
|
3
|
+
## v0.7.0
|
|
4
|
+
|
|
5
|
+
- Make both `increase_limit` and `maximum_size_limit` optional (if `nil`).
|
|
6
|
+
|
|
7
|
+
## v0.6.0
|
|
8
|
+
|
|
9
|
+
- Added `sample_count` attribute to monitor to track number of samples taken.
|
|
10
|
+
- `check!` method in cluster now returns an array of leaking monitors if no block is given.
|
|
11
|
+
- `Cluster#check!` now invokes `Monitor#sample!` to ensure memory usage is updated before checking for leaks.
|
|
12
|
+
|
|
3
13
|
## v0.5.0
|
|
4
14
|
|
|
5
15
|
- Improved variable names.
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: memory-leak
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
|
36
36
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
|
37
37
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
|
38
38
|
-----END CERTIFICATE-----
|
|
39
|
-
date:
|
|
39
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
40
40
|
dependencies: []
|
|
41
41
|
executables: []
|
|
42
42
|
extensions: []
|
|
@@ -63,14 +63,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
63
63
|
requirements:
|
|
64
64
|
- - ">="
|
|
65
65
|
- !ruby/object:Gem::Version
|
|
66
|
-
version: '3.
|
|
66
|
+
version: '3.2'
|
|
67
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
68
|
requirements:
|
|
69
69
|
- - ">="
|
|
70
70
|
- !ruby/object:Gem::Version
|
|
71
71
|
version: '0'
|
|
72
72
|
requirements: []
|
|
73
|
-
rubygems_version: 3.
|
|
73
|
+
rubygems_version: 3.7.2
|
|
74
74
|
specification_version: 4
|
|
75
75
|
summary: A memory leak monitor.
|
|
76
76
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|