acGAN - CUDA out of memory


I am trying to run the following code: for more epochs and I get CUDA out of memory error after around 60.

I am a really noob in Torch and I did not write that code. After researching a bit I think some tensors are not allocated the way they should be so the memory usage increases with each iteration, but I cannot find the problem myself (tried, but it takes 3 hours to get to the error so changing every line of code in every possible way does not work).

Any help would be greatly appreciated.