neo-ai / neo-ai-dlr

Neo-AI-DLR is a common runtime for machine learning models compiled by AWS SageMaker Neo, TVM, or TreeLite.
Apache License 2.0
492 stars 106 forks source link

[Treelite] Add TreeliteModel destructor #407

Closed apivovarov closed 2 years ago

apivovarov commented 2 years ago

Add TreeliteModel destructor

TreeliteModel class has PredictorHandle treelite_model_ member. typedef void* PredictorHandle;

Looks like we have a memory leak issue because we do not delete treelite::Predictor to which treelite_model_ points. treelite_model_ is not wrapped with unique_pointer. wrapping void* with unique_pointer does not work anyway - it needs actual object type such as predictor::Predict.

it is easier to just add explicit cleanup method to TreeliteModel to fix memory leak issue.