File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
lib/async/container/supervisor Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -13,18 +13,22 @@ class MemoryMonitor
13
13
# Create a new memory monitor.
14
14
#
15
15
# @parameter interval [Integer] The interval at which to check for memory leaks.
16
- # @parameter limit [Integer] The limit of memory that a process can consume before being killed .
17
- def initialize ( interval : 10 )
16
+ # @parameter total_size_limit [Integer] The total size limit of all processes, or nil for no limit .
17
+ def initialize ( interval : 10 , total_size_limit : nil , ** options )
18
18
@interval = interval
19
- @cluster = Memory ::Leak ::Cluster . new ( limit : limit )
19
+ @cluster = Memory ::Leak ::Cluster . new ( total_size_limit : total_size_limit )
20
+
21
+ # We use these options when adding processes to the cluster:
22
+ @options = options
23
+
20
24
@processes = Hash . new { |hash , key | hash [ key ] = Set . new . compare_by_identity }
21
25
end
22
26
23
27
# Add a process to the memory monitor. You may override this to control how processes are added to the cluster.
24
28
#
25
29
# @parameter process_id [Integer] The process ID to add.
26
30
def add ( process_id )
27
- @cluster . add ( process_id )
31
+ @cluster . add ( process_id , ** @options )
28
32
end
29
33
30
34
# Remove a process from the memory monitor.
You can’t perform that action at this time.
0 commit comments