Fix a variety of memory leaks around the PeopleView and model
svn: r12791
This commit is contained in:
parent
d45f5970fb
commit
6c855de785
@ -2,6 +2,7 @@
|
|||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||||
|
# Copyright (C) 2009 Gary Burton
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -88,6 +89,9 @@ class NodeTreeMap(object):
|
|||||||
self.sortnames = {}
|
self.sortnames = {}
|
||||||
|
|
||||||
def clear_temp_data(self):
|
def clear_temp_data(self):
|
||||||
|
del self.temp_iter2path
|
||||||
|
del self.temp_path2iter
|
||||||
|
del self.temp_sname_sub
|
||||||
self.temp_iter2path = {}
|
self.temp_iter2path = {}
|
||||||
self.temp_path2iter = {}
|
self.temp_path2iter = {}
|
||||||
self.temp_sname_sub = {}
|
self.temp_sname_sub = {}
|
||||||
@ -240,6 +244,10 @@ class PeopleModel(gtk.GenericTreeModel):
|
|||||||
|
|
||||||
self.db = db
|
self.db = db
|
||||||
self.in_build = False
|
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",
|
Config.client.notify_add("/apps/gramps/preferences/todo-color",
|
||||||
self.update_todo)
|
self.update_todo)
|
||||||
@ -350,11 +358,8 @@ class PeopleModel(gtk.GenericTreeModel):
|
|||||||
"""
|
"""
|
||||||
Calculate the new path to node values for the model.
|
Calculate the new path to node values for the model.
|
||||||
"""
|
"""
|
||||||
|
self.clear_cache()
|
||||||
self.in_build = True
|
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.total = 0
|
||||||
self.displayed = 0
|
self.displayed = 0
|
||||||
@ -373,10 +378,10 @@ class PeopleModel(gtk.GenericTreeModel):
|
|||||||
self.in_build = False
|
self.in_build = False
|
||||||
|
|
||||||
def clear_cache(self):
|
def clear_cache(self):
|
||||||
self.lru_data = LRU(_CACHE_SIZE)
|
self.lru_name.clear()
|
||||||
self.lru_name = LRU(_CACHE_SIZE)
|
self.lru_data.clear()
|
||||||
self.lru_bdate = LRU(_CACHE_SIZE)
|
self.lru_bdate.clear()
|
||||||
self.lru_ddate = LRU(_CACHE_SIZE)
|
self.lru_ddate.clear()
|
||||||
|
|
||||||
def build_sub_entry(self, name):
|
def build_sub_entry(self, name):
|
||||||
self.mapper.build_sub_entry(name)
|
self.mapper.build_sub_entry(name)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# This file is derived from the GPL program "PyPE"
|
# This file is derived from the GPL program "PyPE"
|
||||||
#
|
#
|
||||||
# Copyright (C) 2003-2006 Josiah Carlson
|
# Copyright (C) 2003-2006 Josiah Carlson
|
||||||
|
# Copyright (C) 2009 Gary Burton
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -144,3 +145,9 @@ class LRU(object):
|
|||||||
Return all items
|
Return all items
|
||||||
"""
|
"""
|
||||||
return [data[0] for data in self.iteritems()]
|
return [data[0] for data in self.iteritems()]
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
"""
|
||||||
|
Empties LRU
|
||||||
|
"""
|
||||||
|
self.data.clear()
|
||||||
|
13
src/Utils.py
13
src/Utils.py
@ -2,6 +2,7 @@
|
|||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||||
|
# Copyright (C) 2009 Gary Burton
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# 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.
|
# been alive in the current year then they must be dead.
|
||||||
|
|
||||||
try:
|
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
|
return False
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
raise Errors.DatabaseError(
|
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
|
# If there are ancestors that would be too old in the current year
|
||||||
# then assume our person must be dead too.
|
# 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
|
return False
|
||||||
|
|
||||||
# If we can't find any reason to believe that they are dead we
|
# If we can't find any reason to believe that they are dead we
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||||
|
# Copyright (C) 2009 Gary Burton
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -258,6 +259,8 @@ class Callback(object):
|
|||||||
# signal name clash
|
# signal name clash
|
||||||
sys.stderr.write("Warning: signal name clash: %s\n" % str(k))
|
sys.stderr.write("Warning: signal name clash: %s\n" % str(k))
|
||||||
self.__signal_map[k] = v
|
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
|
# self.__signal_map now contains the connonical list
|
||||||
# of signals that this instance can emit.
|
# of signals that this instance can emit.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user