run_action: gc locals of calling func
authorZac Medico <zmedico@gentoo.org>
Tue, 16 Oct 2012 15:55:22 +0000 (08:55 -0700)
committerZac Medico <zmedico@gentoo.org>
Tue, 16 Oct 2012 15:55:22 +0000 (08:55 -0700)
pym/_emerge/actions.py
pym/_emerge/main.py

index 3336e9fcae74d9a50223d6d7a2c01a36f7ccb0e0..c403d8974fd2e82c83a8d3b6c8099ee9a0d3221c 100644 (file)
@@ -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 \
index fd1fd069bb57c406a0e9da74b663f0a379f11f2e..ef94a4760163d16d7b8866069c8d4cdeb0ea0732 100644 (file)
@@ -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)