Commit ee0494ae authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

use pympler.asizeof.asizeof instead of mx.Tools.sizeof to get more accurate memory usage.

parent 0470ee54
...@@ -37,17 +37,15 @@ from Products.ERP5Type import interfaces ...@@ -37,17 +37,15 @@ from Products.ERP5Type import interfaces
import zope.interface import zope.interface
def calcPythonObjectMemorySize(i): def calcPythonObjectMemorySize(i):
""" Recursive function that will 'walk' over complex python types and caclulate """
their RAM memory usage. """ Returns the memory size of an object.
from mx.Tools import sizeof (returns 0 if the required library is missing).
s = sizeof(i) """
if isinstance(i, dict): try:
for k, v in i.items(): from pympler.asizeof import asizeof
s += calcPythonObjectMemorySize(k) + calcPythonObjectMemorySize(v) return asizeof(i)
elif isinstance(i, (list, tuple)): except ImportError:
for v in i: return 0
s += calcPythonObjectMemorySize(v)
return s
_MARKER = [] _MARKER = []
class RamCache(BaseCache): class RamCache(BaseCache):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment