Skip to content

Commit ded7219

Browse files
rainwoodmantensorflower-gardener
authored andcommitted
Call gc.collect() multiple times in unit test.
In an upcoming change tf.Tensor is switching to proper Python GC. It need several calls to gc.collect() to break reference cycles. PiperOrigin-RevId: 628422487
1 parent ef5f155 commit ded7219

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tensorflow_probability/python/layers/internal/distribution_tensor_coercible_test.py

+4
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,14 @@ def testTypeObjectLeakage(self):
305305
# These weakrefs could potentially come from tf.function.variables.
306306
dist = layer(x)
307307
gc.collect()
308+
gc.collect()
309+
gc.collect()
308310
before_objs = len(gc.get_objects())
309311
for _ in range(int(1e2)):
310312
dist = layer(x)
311313
gc.collect()
314+
gc.collect()
315+
gc.collect()
312316
after_objs = len(gc.get_objects())
313317
del dist
314318

0 commit comments

Comments
 (0)