Garbage collection in Tensorflow 1.14 When a variable is created, it is added to collections to allow sharing and reusing. However, this seems like it's a potential for "memory leaks" (strictly speaking, it's not, since there still exists a reference). How should I deal with this?

If I do something like:

import tensorflow as tf
g = tf.Graph()
with g.as_default():
    tf.get_variable('myvar', shape=(2, 2))
del g


will myvar be garbage collected?
In Tensorflow 1.*, myvar will not be collected even if you lost track of the variable pointing to it, till the Python process terminates. 

In Tensorfow 2.* it will be collected by the garbage collector. 

For details, see the blog by Tensorflow, under the "No more globals" section.