Clearing traced function cache

Skip to first unread message

Feb 14, 2022, 1:55:44 PM2/14/22
to Discuss
 Hi all,
first off, thanks a lot for all the efforts and the great work, it's a pleasure to use TensorFlow!

Is there a public way to clear/invalidate the traced functions? In order to a) retrace it (with a changed Python state) and b) clear up the memory

The use-case is that a function is sometimes (Python) state based and therefore one would need to retrace it, basically invalidating the old trace and removing it.

I am aware that there are often ways around such a design, but sometimes there are None: if you build a model that depends on Python variable and run this a couple of times. Manually keeping track of changes is one thing (this is up to the user, clearly) but we cannot simply check for re-tracing _in general_ (since this would mean that we would also need to handle the re-tracing logic of Tensors).

How could we go about clearing the traced functions?


Rohan Jain

Feb 28, 2022, 1:15:09 AM2/28/22
to Dan Moldovan, Faizan Muhammad,, Discuss
Faizan and Dan have done some recent work in this area that can help you. 

You received this message because you are subscribed to the Google Groups "Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit


Aug 3, 2022, 4:57:48 PM8/3/22
to Discuss,, Discuss, Dan Moldovan, Faizan Muhammad,
Hi All, is there a response or a solution to this problem? 
This memory leak (and maybe other ones) prevent using Tensorflow in production.

Mark Knecht

Aug 3, 2022, 5:25:03 PM8/3/22
to A K, Discuss,, Dan Moldovan, Faizan Muhammad,
Is this list even alive? I haven't seen any messages since last May and very little traffic since last year.

- Mark

Jiri Simsa

Aug 3, 2022, 6:43:30 PM8/3/22
to Mark Knecht, A K, Discuss,, Dan Moldovan, Faizan Muhammad,
The recommended forum for TF related discussion (e.g. asking technical questions) is (which was launched last year).

Reply all
Reply to author
0 new messages