From ec4bbf35a159b5d019d6acd84aa5753b794bb7ee Mon Sep 17 00:00:00 2001 From: Benjamin Schubert Date: Mon, 11 Feb 2019 15:20:00 +0000 Subject: Cleanup internal Loader cache after loading elements --- buildstream/_loader/loader.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'buildstream/_loader/loader.py') diff --git a/buildstream/_loader/loader.py b/buildstream/_loader/loader.py index d0cfa8522..17d7c63fb 100644 --- a/buildstream/_loader/loader.py +++ b/buildstream/_loader/loader.py @@ -152,8 +152,27 @@ class Loader(): # ret.append(loader._collect_element(element)) + self._clean_caches() + return ret + # clean_caches() + # + # Clean internal loader caches, recursively + # + # When loading the elements, the loaders use caches in order to not load the + # same element twice. These are kept after loading and prevent garbage + # collection. Cleaning them explicitely is required. + # + def _clean_caches(self): + for loader in self._loaders.values(): + # value may be None with nested junctions without overrides + if loader is not None: + loader._clean_caches() + + self._meta_elements = {} + self._elements = {} + ########################################### # Private Methods # ########################################### -- cgit v1.2.1