Hi
Maybe I’m doing something wrong, but I’ve noticed a continuous increase in the memory usage when calling torch.jit.trace(model, inputs) multiple times in the same process.
I’m using the following test code:

#Utilities 
import os
import psutil

#JIT trace test
import torch
import torchvision.models as model_zoo

with torch.no_grad():

  #Create a simple resnet 
  model = model_zoo.resnet18()
  model.eval

  #Create sample input
  sample_input = torch.randn(size=[2, 3, 480, 640], requires_grad=False)

  #Get process id
  process = psutil.Process(os.getpid())

  #Repeat tracing 
  for i in range(0, 1000):
    tr_model = torch.jit.trace(model, sample_input, check_trace=False)
    print("Iter: {} = {}".format(i, process.memory_full_info()))


I’m using PyTorch 1.4.0 installed with conda.
I get the same problem with check_trace=True and check_trace=False