Hi,
I have seen the trt sample in /home/nvidia/tegra_multimedia_api/samples/common/algorithm/trt/trt_inference.cpp and the code:
void
TRT_Context::buildTrtContext(const string& deployfile,
const string& modelfile, bool bUseCPUBuf)
{
if (!parseNet(deployfile))
{
cout<<"parse net failed, exit!"<<endl;
exit(0);
}
ifstream trtModelFile("trtModel.cache");
if (trtModelFile.good())
{
// get cache file length
size_t size = 0;
size_t i = 0;
cout<<"Using cached TRT model" <<endl;
// Get the length
trtModelFile.seekg(0, ios::end);
size = trtModelFile.tellg();
trtModelFile.seekg(0, ios::beg);
char * buff = new char ;
while (trtModelFile.get(buff[i])) i++;
trtModelFile.close();
runtime = createInferRuntime(*pLogger);
engine = runtime->deserializeCudaEngine((void *)buff, size, nullptr);
}
else
{
caffeToTRTModel(deployfile, modelfile);
cout<<"Create TRT model cache"<<endl;
ofstream trtModelFile("trtModel.cache");
trtModelFile.write((char *)trtModelStream->data(), trtModelStream->size());
trtModelFile.close();
runtime = createInferRuntime(*pLogger);
engine = runtime->deserializeCudaEngine(trtModelStream->data(), trtModelStream->size(), nullptr);
trtModelStream->destroy();
}
context = engine->createExecutionContext();
allocateMemory(bUseCPUBuf);
}
in line 24:
char * buff = new char ;
does this buff can’t be release or you forgot it ?
I have written a demo such as this sample, but I found the demo would leak 16MB per hour.
Thanks.