diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-11-11 22:56:58 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-11-11 22:56:58 +0000 |
commit | e109bc610f4d1026a30ba9540c31ecb5e138d791 (patch) | |
tree | a29a6e0cabd4f382ad47cc06667f62cbf456b007 | |
parent | 65f86d568973150401641979f1d30e9495003bab (diff) | |
download | portage-e109bc610f4d1026a30ba9540c31ecb5e138d791.tar.gz portage-e109bc610f4d1026a30ba9540c31ecb5e138d791.tar.bz2 portage-e109bc610f4d1026a30ba9540c31ecb5e138d791.zip |
Inside iter_owners, only cache a maximum of 25 dblink instances, in order
to avoid potentially running out of memory.
svn path=/main/trunk/; revision=14815
-rw-r--r-- | pym/portage/dbapi/vartree.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 137e22f26..0be5632c1 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -48,6 +48,7 @@ from portage import _unicode_encode from portage.cache.mappings import slot_dict_class import codecs +from collections import deque import re, shutil, stat, errno, copy, subprocess import logging import os as _os @@ -1618,12 +1619,17 @@ class vardbapi(dbapi): base_names = self._vardb._aux_cache["owners"]["base_names"] dblink_cache = {} + dblink_fifo = deque() def dblink(cpv): x = dblink_cache.get(cpv) if x is None: + if len(dblink_fifo) >= 25: + # Ensure that we don't run out of memory. + del dblink_cache[dblink_fifo.popleft().mycpv] x = self._vardb._dblink(cpv) dblink_cache[cpv] = x + dblink_fifo.append(x) return x for path in path_iter: |