Skip to content

Commit a2973c8

Browse files
committed
fix: set memory limit
1 parent 5d76b34 commit a2973c8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

mutmut/__main__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
dedent,
3737
indent,
3838
)
39+
import resource
40+
3941
from threading import Thread
4042
from typing import (
4143
Dict,
@@ -129,6 +131,10 @@ def guess_paths_to_mutate():
129131
'Could not figure out where the code to mutate is. '
130132
'Please specify it on the command line using --paths-to-mutate, '
131133
'or by adding "paths_to_mutate=code_dir" in setup.cfg to the [mutmut] section.')
134+
135+
def limit_memory(maxsize):
136+
soft, hard = resource.getrlimit(resource.RLIMIT_AS)
137+
resource.setrlimit(resource.RLIMIT_AS, (maxsize, hard))
132138

133139

134140
def record_trampoline_hit(name):
@@ -1226,6 +1232,7 @@ def read_one_child_exit_status():
12261232
# In the child
12271233
os.environ['MUTANT_UNDER_TEST'] = mutant_name
12281234
setproctitle(f'mutmut: {mutant_name}')
1235+
limit_memory(1000*1000*500)
12291236

12301237
# Run fast tests first
12311238
tests = sorted(tests, key=lambda test_name: mutmut.duration_by_test[test_name])

0 commit comments

Comments
 (0)