Hi,
I implemented a C extension to pytorch, in which I create the output tensor through
the TH_API THCudaTensor *THCudaTensor_newWithSize2d function, declared in THTensor.h.
This is then used in pytorch through the cffi.
In the end, I am using this function many times, overriding my variable.
Imagine something like
While True:
   result = myfunction(param1, parma2)
   # do stuff

It turns out that I have a memory leak: my CUDA memory is soon saturated.
Do I need to explicitly call some function to free that tensor ? It doesn’t seem like it’s freed.
Is the good practice to create a Python wrapper to that function, in which I define the output tensor, to be filled by this external module ? Or is there a way to do the allocation there as I do currently, leaving pytorch free this memory somehow ?
Thanks a lot