MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / testGarbageCollected

Method testGarbageCollected

tensorflow/python/framework/ops_test.py:2844–2863  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2842 # theoretically increase the object's refcount to "save" it from gc, and any
2843 # already-deleted objects in the cycle would have be to restored.)
2844 def testGarbageCollected(self):
2845 # Create a graph we can delete and a weak reference to monitor if it's gc'd
2846 g = ops.Graph()
2847 g_ref = weakref.ref(g)
2848 # Create some ops
2849 with g.as_default():
2850 a = constant_op.constant(2.0)
2851 b = constant_op.constant(3.0)
2852 c = math_ops.add(a, b)
2853 # Create a session we can delete
2854 with session.Session(graph=g) as sess:
2855 self.evaluate(c)
2856 # Delete all references and trigger gc
2857 del g
2858 del a
2859 del b
2860 del c
2861 del sess
2862 gc.collect()
2863 self.assertIsNone(g_ref())
2864
2865 def testRunnableAfterInvalidShape(self):
2866 with ops.Graph().as_default():

Callers

nothing calls this directly

Calls 8

as_defaultMethod · 0.95
refMethod · 0.80
collectMethod · 0.80
GraphMethod · 0.45
constantMethod · 0.45
addMethod · 0.45
SessionMethod · 0.45
evaluateMethod · 0.45

Tested by

no test coverage detected