Memory Leak in TVM Run on x64 linux

Hi Experts, As the title say,I found some memory leak in TVM. I use the code from github offical, i build it from source.

git commit: 3ba586803ac7956813177aebf8072e7d7c0ab9b2

I test tvm with onnxmodel:

import onnx
import numpy as np
import tvm
from tvm import te
import tvm.relay as relay


# https://github.com/onnx/models/tree/master/vision/classification/squeezenet
path = r"model/squeezenet1.1-7.onnx"
model = onnx.load(path)
input_name = "data"
shape_dict = {input_name: [1, 3, 224, 224]}
mod, params = relay.frontend.from_onnx(model, shape_dict)


target = "llvm -mcpu=core-avx2"
with relay.build_config(opt_level=3, required_pass=["FastMath"]):
    graph, lib, cparams = relay.build(mod, target, params=params)

import tvm.contrib.graph_runtime as runtime
ctx = tvm.cpu()
rt = runtime.create(graph, lib, ctx)
rt.set_input(**cparams)
inp_data = tvm.nd.array(np.random.uniform(size=(1, 3, 224, 224)).astype(np.float32))
rt.set_input(decoder_inp=inp_data)

import os, psutil
def main():
    process = psutil.Process(os.getpid())
    for i in range(0, 4000):
        rt.run()
        if i % 400 == 0:
            print('i='+str(i)+', Used Memory:', process.memory_info().rss / 1024 / 1024, 'MB')
main()

the start and the end is different !

I saw Memory leak running in cpu mode on windows[tvm 0.6.0] , the bug in openmp was fixed . I don’t konw how to fixed it !

image