diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-11-16 00:30:53 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-11-16 00:30:53 +0000 |
commit | f70d240c7456d3b34d66a9e92d1418c21d62898c (patch) | |
tree | 3ad88aab755d2fa973ccf29836570994ea6254ac | |
parent | 9d25ac92c71e1a0dcd57f0e51d180630a72706ce (diff) | |
download | portage-f70d240c7456d3b34d66a9e92d1418c21d62898c.tar.gz portage-f70d240c7456d3b34d66a9e92d1418c21d62898c.tar.bz2 portage-f70d240c7456d3b34d66a9e92d1418c21d62898c.zip |
Inside iter_owners, only cache a maximum of 25 dblink instances, in order
to avoid potentially running out of memory. (trunk r14815)
svn path=/main/branches/2.1.7/; revision=14833
-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 aae16e43f..cb9c57216 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 @@ -902,12 +903,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: |