Releasing ONNX resources #19286
-
Hi all, I am wondering about the proper way of releasing resources after performing inference. To be more precise, I’m creating an Ort::Env and Ort::Session objects dynamically for some reason; i.e. I have pointers to these objects (using the C++ API). Previously, I had been using the usual “delete”s for deallocating the memory for these objects but then realized that there are member functions “release()” for each of these classes. So my question is: should I explicitly call these functions to release reources or the usual “delete”s on the pointers enough for releasing the associated resources? Likewise, should I call the release methods explicitly for the input and output tensors used in the “Run()” method of the Ort::Session? PS. I’m using ONNX version 1.14.1. Any help on this matter will be much appreciated. Thanks a lot in advance… |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You don't have to create Ort::Env and Ort::Session objects dynamically. They call the appropriate Release function in their destructor when they go out of scope. |
Beta Was this translation helpful? Give feedback.
You don't have to create Ort::Env and Ort::Session objects dynamically. They call the appropriate Release function in their destructor when they go out of scope.