If we don't collect tracing, always free the trace data (#42118)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/42118
We toggle trace on with a certain probablility. In the case of 3 inferences with trace on/off/on. We leak the trace from the first inference. Always clean up the trace will fix it.
Test Plan:
predictor
I created a tiny repro here: D22786551
With this fix, this issue is gone.
Reviewed By: gcatron
Differential Revision: D22768382
fbshipit-source-id: 9ee0bbcb2bc5f76107dae385759fe578909a683d