Commit fa2330a1 authored by Ivan Tyagov's avatar Ivan Tyagov

Remove dependency on guppy-pe (doesn't work on 64bits platforms).

Use mxBase product to measure memory usage.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16859 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2b9218c7
......@@ -33,16 +33,17 @@ from Products.ERP5Type.Cache import DEFAULT_CACHE_SCOPE
from BaseCache import *
import time
def calcPythonObjectMemorySize(h, i):
def calcPythonObjectMemorySize(i):
""" Recursive function that will 'walk' over complex python types and caclulate
their RAM memory usage. """
s = h.iso(i).size
from mx.Tools import sizeof
s = sizeof(i)
if isinstance(i, dict):
for k, v in i.items():
s += calcPythonObjectMemorySize(h, k) + calcPythonObjectMemorySize(h, v)
s += calcPythonObjectMemorySize(k) + calcPythonObjectMemorySize(v)
elif isinstance(i, list) or isinstance(i, tuple):
for v in i:
s += calcPythonObjectMemorySize(h, v)
s += calcPythonObjectMemorySize(v)
return s
class RamCache(BaseCache):
......@@ -129,15 +130,13 @@ class RamCache(BaseCache):
def getCachePluginTotalMemorySize(self):
""" Calculate total RAM memory size of cache plugin.
This function depends on guppy python module:
http://guppy-pe.sourceforge.net/
This function depends on mxBase python module:
http://www.egenix.com/products/python/mxBase/
"""
from guppy import hpy
h = hpy()
total_size = 0
cache_keys_total_size = {}
for cache_key, cache_value in self._cache_dict[DEFAULT_CACHE_SCOPE].items():
cache_item_size = calcPythonObjectMemorySize(h, cache_value.getValue())
cache_item_size = calcPythonObjectMemorySize(cache_value.getValue())
total_size += cache_item_size
cache_keys_total_size[cache_key] = cache_item_size
return total_size, cache_keys_total_size
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