From e9fd283aedf54e2effc73f4157524fe9a26993c0 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 16 Oct 2012 08:55:22 -0700 Subject: run_action: gc locals of calling func --- pym/_emerge/actions.py | 9 ++++++++- pym/_emerge/main.py | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index 3336e9fca..c403d8974 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -3426,7 +3426,14 @@ def repo_name_duplicate_check(trees): return bool(ignored_repos) -def run_action(settings, trees, mtimedb, myaction, myopts, myfiles): +def run_action(settings, trees, mtimedb, myaction, myopts, myfiles, + gc_locals=None): + + # The caller may have its local variables garbage collected, so + # they don't consume any memory during this long-running function. + if gc_locals is not None: + gc_locals() + gc_locals = None # skip global updates prior to sync, since it's called after sync if myaction not in ('help', 'info', 'sync', 'version') and \ diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index fd1fd069b..ef94a4760 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -999,4 +999,5 @@ def emerge_main(args=None): tmpcmdline.extend(args) myaction, myopts, myfiles = parse_opts(tmpcmdline) - return run_action(settings, trees, mtimedb, myaction, myopts, myfiles) + return run_action(settings, trees, mtimedb, myaction, myopts, myfiles, + gc_locals=locals().clear) -- cgit v1.2.3-1-g7c22