Commit 51c40496 authored by Eugene Brevdo's avatar Eugene Brevdo Committed by Amit Patankar
Browse files

Fix memory leak in python caused by @tf_should_use.

The issue is that python's GC has trouble collecting objects with __del__ methods.

The solution is two pronged:
* Keep track of usage state outside of the class, via a dict mapping
  id(object) => state
* Remove __del__ (this was the source: python's GC couldn't collect wrapped
  objects), and instead use weakref.finalize to emit warnings just as the object
  is being garbage collected.
* Added tests for garbage collection [they were failing before i fixed the issue]

PiperOrigin-RevId: 158042388
parent a823c8d4
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment