I have a python script, whose memory usage (observed in `top`) is growing indefinitely when the script is running.

My script is not supposed to store anything. It just receives some request (REST API), processes the request, and returns some result. The expected behaviour is that the memory usage stays constant.

I'm looking for a suitable memory profiler tool that would allow me to identify where the growing object is located in the code.

I had a look at [FIL-profiler](https://pythonspeed.com/products/filmemoryprofiler/), but it seems to aim at considering "peak memory usage", which is I believe not my case.

thanks

EDIT1: I wanted to give [pyrasite](https://pypi.org/project/pyrasite) a try, but I could not make it work. Since the last update of this project is 2012 May, it may be that it is not anymore compatible with the current python (I'm using 3.8)

EDIT2: I gave a try to [Pympler](https://pypi.org/project/Pympler/), following [this post](https://stackoverflow.com/a/48054801/1867458). I added the following code to my script:

```
from pympler import muppy, summary
all_objects = muppy.get_objects()
sum = summary.summarize(all_objects)
summary.print_(sum)

```

This outputs:

```
    types |   # objects |   total size
========= | =========== | ============
     dict |        7628 |      3.15 MB
      str |       24185 |      2.71 MB
     type |        1649 |      1.39 MB
    tuple |       13722 |      1.35 MB
     code |        7701 |      1.06 MB
      set |         398 |    453.06 KB
....

```

Which does not show any suspiciously large object (the scripts, when running, accumulates a memory usage going to GB scale)

EDIT3:
I tried with `tracemalloc`: I put a `tracemalloc.start()` at the beginning of the script, then, at the end of the script, but before stopping (so that the memory usage is visibly very high, according to `top`), I do a

```
snapshot = tracemalloc.take_snapshot()
display_top(snapshot)

```

This displays the lines of code with maximal memory usage. But still, nothing in comparison to that observed in `top`.
I tried also a gc.collect(), but this has no effect.