Solved by albanD in post #2 
              
              
                This most likely happen because you either store things in a list that ever grows at each iteration or if you hold onto the computational graph of the whole history. 
You should be able to check the first one by printing list size in your code (in particular, buffer) 
For the second one, you want to…