Skip to content

Commit 5573e54

Browse files
committed
ENH: Explicit garbage collection in MultiProc
1 parent d6c4957 commit 5573e54

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

nipype/pipeline/plugins/multiproc.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from multiprocessing import Process, Pool, cpu_count, pool
1313
from traceback import format_exception
1414
import sys
15+
import gc
1516

1617
from copy import deepcopy
1718
import numpy as np
@@ -230,6 +231,9 @@ def _send_procs_to_workers(self, updatehash=False, graph=None):
230231

231232
jobids = self._sort_jobs(jobids, scheduler=self.plugin_args.get('scheduler'))
232233

234+
# Run garbage collector before potentially submitting jobs
235+
gc.collect()
236+
233237
# Submit jobs
234238
for jobid in jobids:
235239
# First expand mapnodes
@@ -292,6 +296,9 @@ def _send_procs_to_workers(self, updatehash=False, graph=None):
292296
free_processors += next_job_th
293297
# Display stats next loop
294298
self._stats = None
299+
300+
# Clean up any debris from running node in main process
301+
gc.collect()
295302
continue
296303

297304
# Task should be submitted to workers

0 commit comments

Comments
 (0)