mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
fix memory leak
This commit is contained in:
parent
fec518af71
commit
d5d23c2fa7
@ -1199,3 +1199,34 @@ class TaskManager:
|
|||||||
del l
|
del l
|
||||||
tm.destroy()
|
tm.destroy()
|
||||||
del tm
|
del tm
|
||||||
|
|
||||||
|
if __debug__:
|
||||||
|
def checkLeak():
|
||||||
|
import sys
|
||||||
|
import gc
|
||||||
|
gc.enable()
|
||||||
|
from direct.showbase.DirectObject import DirectObject
|
||||||
|
class TestClass(DirectObject):
|
||||||
|
def doTask(self, task):
|
||||||
|
return task.done
|
||||||
|
obj = TestClass()
|
||||||
|
startRefCount = sys.getrefcount(obj)
|
||||||
|
print 'sys.getrefcount(obj): %s' % sys.getrefcount(obj)
|
||||||
|
print '** addTask'
|
||||||
|
t = obj.addTask(obj.doTask, 'test')
|
||||||
|
print 'sys.getrefcount(obj): %s' % sys.getrefcount(obj)
|
||||||
|
print 'task.getRefCount(): %s' % t.getRefCount()
|
||||||
|
print '** removeTask'
|
||||||
|
obj.removeTask('test')
|
||||||
|
print 'sys.getrefcount(obj): %s' % sys.getrefcount(obj)
|
||||||
|
print 'task.getRefCount(): %s' % t.getRefCount()
|
||||||
|
print '** step'
|
||||||
|
taskMgr.step()
|
||||||
|
taskMgr.step()
|
||||||
|
taskMgr.step()
|
||||||
|
print 'sys.getrefcount(obj): %s' % sys.getrefcount(obj)
|
||||||
|
print 'task.getRefCount(): %s' % t.getRefCount()
|
||||||
|
print '** task release'
|
||||||
|
t = None
|
||||||
|
print 'sys.getrefcount(obj): %s' % sys.getrefcount(obj)
|
||||||
|
assert sys.getrefcount(obj) == startRefCount
|
||||||
|
@ -64,6 +64,8 @@ PythonTask::
|
|||||||
Py_DECREF(_args);
|
Py_DECREF(_args);
|
||||||
Py_DECREF(_dict);
|
Py_DECREF(_dict);
|
||||||
Py_XDECREF(_generator);
|
Py_XDECREF(_generator);
|
||||||
|
Py_XDECREF(_owner);
|
||||||
|
Py_XDECREF(_upon_death);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user