Fix ProxyCache to deal with memory leak
This commit is contained in:
parent
4ae4ac1d12
commit
b26b34fba9
@ -40,7 +40,13 @@ class CacheProxyDb:
|
|||||||
proxies.
|
proxies.
|
||||||
"""
|
"""
|
||||||
self.db = database
|
self.db = database
|
||||||
self.clear_cache()
|
# Memory allocation is power of 2 where slots has to fit.
|
||||||
|
# LRU uses one extra slot in its work, so set max to 2^17-1
|
||||||
|
# otherwise we are just wasting memory
|
||||||
|
self.cache_handle = LRU(131071)
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
self.cache_handle.clear()
|
||||||
|
|
||||||
def __getattr__(self, attr):
|
def __getattr__(self, attr):
|
||||||
"""
|
"""
|
||||||
@ -57,10 +63,7 @@ class CacheProxyDb:
|
|||||||
if handle:
|
if handle:
|
||||||
del self.cache_handle[handle]
|
del self.cache_handle[handle]
|
||||||
else:
|
else:
|
||||||
# Memory allocation is power of 2 where slots has to fit.
|
self.cache_handle.clear()
|
||||||
# LRU uses one extra slot in its work, so set max to 2^17-1
|
|
||||||
# otherwise we are just wasting memory
|
|
||||||
self.cache_handle = LRU(131071)
|
|
||||||
|
|
||||||
def get_person_from_handle(self, handle):
|
def get_person_from_handle(self, handle):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user