Skip to content

Commit 86de411

Browse files
committed
Expose MemoryMonitor cluster options.
1 parent 7794e8a commit 86de411

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/async/container/supervisor/memory_monitor.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,22 @@ class MemoryMonitor
1313
# Create a new memory monitor.
1414
#
1515
# @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)
1818
@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+
2024
@processes = Hash.new{|hash, key| hash[key] = Set.new.compare_by_identity}
2125
end
2226

2327
# Add a process to the memory monitor. You may override this to control how processes are added to the cluster.
2428
#
2529
# @parameter process_id [Integer] The process ID to add.
2630
def add(process_id)
27-
@cluster.add(process_id)
31+
@cluster.add(process_id, **@options)
2832
end
2933

3034
# Remove a process from the memory monitor.

0 commit comments

Comments
 (0)