Clear dbapi caches just after deleting the depgraph in action_build().
authorZac Medico <zmedico@gentoo.org>
Sun, 17 Aug 2008 19:23:54 +0000 (19:23 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 17 Aug 2008 19:23:54 +0000 (19:23 -0000)
This trims down the heap size by a few megs, for bug #229069.
(trunk r10769)

svn path=/main/branches/2.1.2/; revision=11428

bin/emerge

index 88e1b94785964d44afd58c2e8453443abfd55339..51bcdcad67df9198b6e67e6efc25e556cd2ef98a 100755 (executable)
@@ -20,6 +20,7 @@ try:
 except KeyboardInterrupt:
        sys.exit(1)
 
+import gc
 import os, stat
 
 os.environ["PORTAGE_LEGACY_GLOBALS"] = "false"
@@ -8654,6 +8655,8 @@ def action_build(settings, trees, mtimedb,
                                time.sleep(3) # allow the parent to have first fetch
                        mymergelist = mydepgraph.altlist()
                        del mydepgraph
+                       clear_caches(trees)
+
                        retval = mergetask.merge(mymergelist, favorites, mtimedb)
                        merge_count = mergetask.curval
                else:
@@ -8695,6 +8698,8 @@ def action_build(settings, trees, mtimedb,
                        pkglist = mydepgraph.altlist()
                        mydepgraph.saveNomergeFavorites()
                        del mydepgraph
+                       clear_caches(trees)
+
                        mergetask = MergeTask(settings, trees, myopts)
                        retval = mergetask.merge(pkglist, favorites, mtimedb)
                        merge_count = mergetask.curval
@@ -8817,6 +8822,14 @@ def validate_ebuild_environment(trees):
                settings = trees[myroot]["vartree"].settings
                settings.validate()
 
+def clear_caches(trees):
+       for d in trees.itervalues():
+               d["porttree"].dbapi.melt()
+               d["porttree"].dbapi._aux_cache.clear()
+               d["bintree"].dbapi._aux_cache.clear()
+               d["bintree"].dbapi._clear_cache()
+       gc.collect()
+
 def load_emerge_config(trees=None):
        kwargs = {}
        for k, envvar in (("config_root", "PORTAGE_CONFIGROOT"), ("target_root", "ROOT")):