diff --git a/oslo_service/service.py b/oslo_service/service.py index e7c8e859..f9803df3 100644 --- a/oslo_service/service.py +++ b/oslo_service/service.py @@ -21,6 +21,7 @@ import abc import collections import copy import errno +import gc import io import logging import os @@ -528,6 +529,13 @@ class ProcessLauncher(object): _check_service_base(service) wrap = ServiceWrapper(service, workers) + # Hide existing objects from the garbage collector, so that most + # existing pages will remain in shared memory rather than being + # duplicated between subprocesses in the GC mark-and-sweep. (Requires + # Python 3.7 or later.) + if hasattr(gc, 'freeze'): + gc.freeze() + LOG.info('Starting %d workers', wrap.workers) while self.running and len(wrap.children) < wrap.workers: self._start_child(wrap)