mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
don't leak DOs that fail to cache
This commit is contained in:
parent
9a0cfd2725
commit
fb964c3d16
@ -20,6 +20,7 @@ class CRCache:
|
|||||||
"""
|
"""
|
||||||
assert self.checkCache()
|
assert self.checkCache()
|
||||||
CRCache.notify.debug("Flushing the cache")
|
CRCache.notify.debug("Flushing the cache")
|
||||||
|
# NOTE: delayDeleted objects should no longer get into the cache in the first place
|
||||||
# give objects a chance to clean themselves up before checking for DelayDelete leaks
|
# give objects a chance to clean themselves up before checking for DelayDelete leaks
|
||||||
messenger.send('clientCleanup')
|
messenger.send('clientCleanup')
|
||||||
# some of these objects might be holding delayDeletes on others
|
# some of these objects might be holding delayDeletes on others
|
||||||
@ -53,6 +54,7 @@ class CRCache:
|
|||||||
# Get the doId
|
# Get the doId
|
||||||
doId = distObj.getDoId()
|
doId = distObj.getDoId()
|
||||||
# Error check
|
# Error check
|
||||||
|
success = False
|
||||||
if self.dict.has_key(doId):
|
if self.dict.has_key(doId):
|
||||||
CRCache.notify.warning("Double cache attempted for distObj "
|
CRCache.notify.warning("Double cache attempted for distObj "
|
||||||
+ str(doId))
|
+ str(doId))
|
||||||
@ -64,6 +66,8 @@ class CRCache:
|
|||||||
self.fifo.append(distObj)
|
self.fifo.append(distObj)
|
||||||
self.dict[doId] = distObj
|
self.dict[doId] = distObj
|
||||||
|
|
||||||
|
success = True
|
||||||
|
|
||||||
if len(self.fifo) > self.maxCacheItems:
|
if len(self.fifo) > self.maxCacheItems:
|
||||||
# if the cache is full, pop the oldest item
|
# if the cache is full, pop the oldest item
|
||||||
oldestDistObj = self.fifo.pop(0)
|
oldestDistObj = self.fifo.pop(0)
|
||||||
@ -74,6 +78,7 @@ class CRCache:
|
|||||||
|
|
||||||
# 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)
|
||||||
|
return success
|
||||||
|
|
||||||
def retrieve(self, doId):
|
def retrieve(self, doId):
|
||||||
assert self.checkCache()
|
assert self.checkCache()
|
||||||
|
@ -478,7 +478,9 @@ class ClientRepositoryBase(ConnectionRepository):
|
|||||||
# 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
|
||||||
if distObj.getCacheable() and distObj.getDelayDeleteCount() <= 0:
|
if distObj.getCacheable() and distObj.getDelayDeleteCount() <= 0:
|
||||||
cache.cache(distObj)
|
cached = cache.cache(distObj)
|
||||||
|
if not cached:
|
||||||
|
distObj.deleteOrDelay()
|
||||||
else:
|
else:
|
||||||
distObj.deleteOrDelay()
|
distObj.deleteOrDelay()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user