diff --git a/src/DisplayModels/_PeopleModel.py b/src/DisplayModels/_PeopleModel.py index d730d59f2..cfe92b76a 100644 --- a/src/DisplayModels/_PeopleModel.py +++ b/src/DisplayModels/_PeopleModel.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham +# Copyright (C) 2009 Gary Burton # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -88,6 +89,9 @@ class NodeTreeMap(object): self.sortnames = {} def clear_temp_data(self): + del self.temp_iter2path + del self.temp_path2iter + del self.temp_sname_sub self.temp_iter2path = {} self.temp_path2iter = {} self.temp_sname_sub = {} @@ -240,6 +244,10 @@ class PeopleModel(gtk.GenericTreeModel): self.db = db self.in_build = False + self.lru_data = LRU(_CACHE_SIZE) + self.lru_name = LRU(_CACHE_SIZE) + self.lru_bdate = LRU(_CACHE_SIZE) + self.lru_ddate = LRU(_CACHE_SIZE) Config.client.notify_add("/apps/gramps/preferences/todo-color", self.update_todo) @@ -350,11 +358,8 @@ class PeopleModel(gtk.GenericTreeModel): """ Calculate the new path to node values for the model. """ + self.clear_cache() self.in_build = True - self.lru_data = LRU(_CACHE_SIZE) - self.lru_name = LRU(_CACHE_SIZE) - self.lru_bdate = LRU(_CACHE_SIZE) - self.lru_ddate = LRU(_CACHE_SIZE) self.total = 0 self.displayed = 0 @@ -373,10 +378,10 @@ class PeopleModel(gtk.GenericTreeModel): self.in_build = False def clear_cache(self): - self.lru_data = LRU(_CACHE_SIZE) - self.lru_name = LRU(_CACHE_SIZE) - self.lru_bdate = LRU(_CACHE_SIZE) - self.lru_ddate = LRU(_CACHE_SIZE) + self.lru_name.clear() + self.lru_data.clear() + self.lru_bdate.clear() + self.lru_ddate.clear() def build_sub_entry(self, name): self.mapper.build_sub_entry(name) diff --git a/src/Lru.py b/src/Lru.py index 64858dc9e..ec623b240 100644 --- a/src/Lru.py +++ b/src/Lru.py @@ -1,6 +1,7 @@ # This file is derived from the GPL program "PyPE" # # Copyright (C) 2003-2006 Josiah Carlson +# Copyright (C) 2009 Gary Burton # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -144,3 +145,9 @@ class LRU(object): Return all items """ return [data[0] for data in self.iteritems()] + + def clear(self): + """ + Empties LRU + """ + self.data.clear() diff --git a/src/Utils.py b/src/Utils.py index 4ba5ff420..f7e07495b 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham +# Copyright (C) 2009 Gary Burton # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -590,7 +591,11 @@ def probably_alive(person, db, current_date=None, limit=0): # been alive in the current year then they must be dead. try: - if descendants_too_old(person, _MIN_GENERATION_YEARS): + age_too_old = descendants_too_old(person, _MIN_GENERATION_YEARS) + # Set to None otherwise there is a memory leak as this function + # is recursive + descendants_too_old = None + if age_too_old: return False except RuntimeError: raise Errors.DatabaseError( @@ -653,7 +658,11 @@ def probably_alive(person, db, current_date=None, limit=0): # If there are ancestors that would be too old in the current year # then assume our person must be dead too. - if ancestors_too_old (person, current_date.get_year()): + # Set to None otherwise there is a memory leak as this function + # is recursive + age_too_old = ancestors_too_old (person, current_date.get_year()) + ancestors_too_old = None + if age_too_old: return False # If we can't find any reason to believe that they are dead we diff --git a/src/gen/utils/callback.py b/src/gen/utils/callback.py index 3164f6303..04c98878d 100644 --- a/src/gen/utils/callback.py +++ b/src/gen/utils/callback.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2005 Donald N. Allingham +# Copyright (C) 2009 Gary Burton # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -258,6 +259,8 @@ class Callback(object): # signal name clash sys.stderr.write("Warning: signal name clash: %s\n" % str(k)) self.__signal_map[k] = v + # Set to None to prevent a memory leak in this recursive function + trav = None # self.__signal_map now contains the connonical list # of signals that this instance can emit.