proactive leak detection for distributed objects

This commit is contained in:
Darren Ranalli 2008-10-21 19:00:30 +00:00
parent c19665e627
commit e185892eb1
2 changed files with 14 additions and 3 deletions

View File

@ -32,6 +32,9 @@ class CRCache:
distObj.deleteOrDelay() distObj.deleteOrDelay()
if distObj.getDelayDeleteCount() != 0: if distObj.getDelayDeleteCount() != 0:
delayDeleted.append(distObj) delayDeleted.append(distObj)
if distObj.getDelayDeleteCount() <= 0:
# make sure we're not leaking
distObj.detectLeaks()
# now that all objects have had a chance to delete, are there any objects left # now that all objects have had a chance to delete, are there any objects left
# that are still delayDeleted? # that are still delayDeleted?
delayDeleteLeaks = [] delayDeleteLeaks = []
@ -76,6 +79,9 @@ class CRCache:
del(self.dict[oldestDistObj.getDoId()]) del(self.dict[oldestDistObj.getDoId()])
# and delete it # and delete it
oldestDistObj.deleteOrDelay() oldestDistObj.deleteOrDelay()
if oldestDistObj.getDelayDeleteCount() <= 0:
# make sure we're not leaking
oldestDistObj.detectLeaks()
# Make sure that the fifo and the dictionary are sane # Make sure that the fifo and the dictionary are sane
assert len(self.dict) == len(self.fifo) assert len(self.dict) == len(self.fifo)
@ -109,6 +115,9 @@ class CRCache:
self.fifo.remove(distObj) self.fifo.remove(distObj)
# and delete it # and delete it
distObj.deleteOrDelay() distObj.deleteOrDelay()
if distObj.getDelayDeleteCount() <= 0:
# make sure we're not leaking
distObj.detectLeaks()
def checkCache(self): def checkCache(self):
# For debugging; this verifies that the cache is sensible and # For debugging; this verifies that the cache is sensible and

View File

@ -490,12 +490,14 @@ class ClientRepositoryBase(ConnectionRepository):
# object; this way we don't clutter up the caches with # object; this way we don't clutter up the caches with
# trivial objects that don't benefit from caching. # trivial objects that don't benefit from caching.
# also don't try to cache an object that is delayDeleted # also don't try to cache an object that is delayDeleted
cached = False
if distObj.getCacheable() and distObj.getDelayDeleteCount() <= 0: if distObj.getCacheable() and distObj.getDelayDeleteCount() <= 0:
cached = cache.cache(distObj) cached = cache.cache(distObj)
if not cached: if not cached:
distObj.deleteOrDelay()
else:
distObj.deleteOrDelay() distObj.deleteOrDelay()
if distObj.getDelayDeleteCount() <= 0:
# make sure we're not leaking
distObj.detectLeaks()
elif self.deferredDoIds.has_key(doId): elif self.deferredDoIds.has_key(doId):
# The object had been deferred. Great; we don't even have # The object had been deferred. Great; we don't even have