From f4b45258589185fd8bb7f220470a72650dc792f8 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Mon, 15 Jun 2015 00:02:16 +0100 Subject: [PATCH] update.py: fix memory leaks We're kind of abusing some bitbake internals here and the result is that there are a bunch of global lists and caches that simply grow as we parse more layers, until available memory is exhausted. We don't care about the contents of any of these within the layer index update script so just clear them out between layers. Should fix [YOCTO #7663]. Signed-off-by: Paul Eggleton --- layerindex/update.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/layerindex/update.py b/layerindex/update.py index a56507b..50a7932 100755 --- a/layerindex/update.py +++ b/layerindex/update.py @@ -582,6 +582,19 @@ def main(): transaction.rollback() else: transaction.commit() + + # Slightly hacky way of avoiding memory leaks + bb.event.ui_queue = [] + bb.parse.parse_py.BBHandler.cached_statements = {} + bb.codeparser.codeparsercache = bb.codeparser.CodeParserCache() + bb.codeparser.codecache = bb.codeparser.SetCache() + bb.fetch._checksum_cache = bb.checksum.FileChecksumCache() + bb.fetch.urldata_cache = {} + bb.fetch.saved_headrevs = {} + bb.parse.__pkgsplit_cache__={} + bb.parse.__mtime_cache = {} + bb.parse.init_parser(tinfoil.config_data) + except KeyboardInterrupt: transaction.rollback() logger.warn("Update interrupted, changes to %s rolled back" % layer.name)