C++ API: Why does my application have a memory leak after calling the Session::sendTaskInput() method?
The Session::sendTaskInput(...) method returns a pointer to a TaskInputHandle object that is created on the heap. You need to assign the return value of Session::sendTaskInput(...) to a TaskInputHandlePtr smart pointer, even if you have no intention of using the TaskInputHandle. The memory will be released once the TaskInputHandlePtr object goes out of scope.
The following code introduces a memory leak
by failing to manage the TaskInputHandle:
{
session->sendTaskInput(inputAttributes); // Leaks TaskInputHandle
}
Use the following code to avoid memory leak:
{
TaskInputHandlePtr inputHandle = session->sendTaskInput(inputAttributes);
} // Memory freed when TaskInputHandlePtr smart pointer goes out of scope.