Memory leak from using tf.constant in loop in TF 2.16
Hi @declanoller ,

I have tested the code in `tf-nightly` (dev20240520) and found no memory leak. Please refer to attached [gist](https://colab.sandbox.google.com/gist/SuryanarayanaY/4603b74112e4f44001adfbe2af216abe/68196.ipynb). Tested with Tf2.16 also and found no memory leak.[Gist](https://colab.sandbox.google.com/gist/SuryanarayanaY/a991b1b0f0c09115e04278ac9f168700/68196.ipynb) for reference. @SuryanarayanaY what python version?

I have two machines. Both have TF 2.16.1. However, running the same code on the one with python 3.10 does *not* leak, while the machine (in the OP) with 3.12 does leak.

edit: I added a `print(sys.version)` to your gist, it looks like it's using 3.10:
```
2.16.1
3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
```

Can you test it with 3.12 somehow?
### Issue type

Bug

### Have you reproduced the bug with TensorFlow Nightly?

No

### Source

binary from pip

### TensorFlow version

2.16.1

### Custom code

Yes

### OS platform and distribution

Linux Ubuntu 24.04

### Mobile device

_No response_

### Python version

3.12.3

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

I believe I tracked down a memory leak in my code to a `tf.constant` creation in a short lived object of a class. I can reproduce it in an even simpler way by just creating the constant in a loop. No `@tf.function` decoration or model training necessary to cause it. It seems to happen if I replace the `tf.constant` with a `tf.random.uniform()`. I tried suggestions I've seen elsewhere, like trying to use `del` on the variable followed by `gc.collect()`.

Some similar looking bug reports:
- https://github.com/tensorflow/tensorflow/issues/57982 
- https://github.com/tensorflow/tensorflow/issues/50765
- https://discuss.tensorflow.org/t/tensorflow-memory-leak-during-inference-in-loop/23044

It looks like upgrading to 2.15 solved it for some people, but it appears to be back in 2.16?

is this expected and I'm doing something wrong?

### Standalone code to reproduce the issue

```shell
import time
import psutil
import tensorflow as tf


def loop_copy():
    for _ in range(2000):
        y = tf.constant(5.0)  # still leaks with this


start_mem = psutil.Process().memory_info().rss

for _ in range(500):
    time.sleep(0.1)
    print((psutil.Process().memory_info().rss - start_mem) / 10**6)
    loop_copy()
```
```


### Relevant log output

```shell
0.0
6.029312
6.815744
7.471104
8.126464
8.781824
9.437184
10.092544
10.747904
11.534336
12.189696
12.845056
13.500416
14.155776
14.811136
15.597568
16.252928
...
```
