The memory is increasing as each forward pass creates intermediate variables, which are used to calculate the gradients. So it shouldn’t be a memory leak.
If you just need the features without backpropagating through your model, you should wrap your code in with torch.no_grad(): to avoid storing the intermediates.
Could you explain the second point a bit? I’m not sure, what the fourth pass would be.