[Erp5-report] r39031 jm - /erp5/trunk/products/ERP5/mixin/composition.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Oct 11 21:26:30 CEST 2010
Author: jm
Date: Mon Oct 11 21:26:27 2010
New Revision: 39031
URL: http://svn.erp5.org?rev=39031&view=rev
Log:
composition: fix severe memory leak (and speed loss)
Modified:
erp5/trunk/products/ERP5/mixin/composition.py
Modified: erp5/trunk/products/ERP5/mixin/composition.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/mixin/composition.py?rev=39031&r1=39030&r2=39031&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/mixin/composition.py [utf8] (original)
+++ erp5/trunk/products/ERP5/mixin/composition.py [utf8] Mon Oct 11 21:26:27 2010
@@ -104,11 +104,18 @@ class asComposedDocument(object):
Collecting predicates (from effective models) is done lazily. Predicates can
be accessed through contentValues/objectValues.
"""
+ # Cache created classes to make other caches (like Base.aq_portal_type)
+ # useful and avoid memory leaks.
+ __class_cache = {}
def __new__(cls, orig_self, portal_type_list=None):
self = orig_self.asContext(_portal_type_list=portal_type_list)
base_class = self.__class__
- self.__class__ = type(base_class.__name__, (cls, base_class), {})
+ try:
+ self.__class__ = cls.__class_cache[base_class]
+ except KeyError:
+ cls.__class_cache[base_class] = self.__class__ = \
+ type(base_class.__name__, (cls, base_class), {})
self._effective_model_list = \
orig_self._findEffectiveSpecialiseValueList(portal_type_list)
return self
More information about the Erp5-report
mailing list