* Changes to observers and service manager APIs.
* Use nsIComponentManagerObsolete. * Fix weak reference leaks * Cache interface infos better for significant perf increase. * Better tests for leaks Not part of the build. git-svn-id: svn://10.0.0.236/trunk@111534 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -29,4 +29,10 @@ for arg in sys.argv[1:]:
|
||||
if arg[0] not in "-/":
|
||||
tests.append(arg)
|
||||
tests = tests or test.regrtest.findtests(path, [])
|
||||
test.regrtest.main(tests, path)
|
||||
try:
|
||||
test.regrtest.main(tests, path)
|
||||
finally:
|
||||
from xpcom import _xpcom
|
||||
_xpcom.NS_ShutdownXPCOM() # To get leak stats and otherwise ensure life is good.
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#
|
||||
|
||||
DEPTH =..\..\..\..\..
|
||||
MODULE=pyxpcom_test
|
||||
|
||||
|
||||
################################################################################
|
||||
## exports
|
||||
|
||||
@@ -19,6 +19,12 @@
|
||||
from xpcom import components, _xpcom
|
||||
import xpcom.server, xpcom.client
|
||||
|
||||
try:
|
||||
from sys import gettotalrefcount
|
||||
except ImportError:
|
||||
# Not a Debug build - assume no references (can't be leaks then :-)
|
||||
gettotalrefcount = lambda: 0
|
||||
|
||||
num_alive = 0
|
||||
|
||||
class koTestSimple:
|
||||
@@ -61,6 +67,30 @@ def test():
|
||||
if num_alive != 0: raise RuntimeError, "Eeek - there are %d objects alive" % (num_alive,)
|
||||
if wr() is not None: raise RuntimeError, "Our weak-reference is not returning None when it should!"
|
||||
|
||||
def test_refcount(num_loops=-1):
|
||||
# Do the test lots of times - can help shake-out ref-count bugs.
|
||||
if num_loops == -1: num_loops = 10
|
||||
for i in xrange(num_loops):
|
||||
test()
|
||||
|
||||
if i==0:
|
||||
# First loop is likely to "leak" as we cache things.
|
||||
# Leaking after that is a problem.
|
||||
num_refs = gettotalrefcount()
|
||||
|
||||
lost = gettotalrefcount() - num_refs
|
||||
# Sometimes we get spurious counts off by 1 or 2.
|
||||
# This can't indicate a real leak, as we have looped
|
||||
# more than twice!
|
||||
if abs(lost)>2:
|
||||
print "*** Lost %d references" % (lost,)
|
||||
|
||||
test()
|
||||
test_refcount()
|
||||
|
||||
print "Weak-reference tests appear to have worked!"
|
||||
if __name__=='__main__':
|
||||
_xpcom.NS_ShutdownXPCOM()
|
||||
ni = xpcom._xpcom._GetInterfaceCount()
|
||||
ng = xpcom._xpcom._GetGatewayCount()
|
||||
if ni or ng:
|
||||
print "********* WARNING - Leaving with %d/%d objects alive" % (ni,ng)
|
||||
|
||||
Reference in New Issue
Block a user