diff --git a/lite/api/paddle_api.cc b/lite/api/paddle_api.cc index a3d29dff93155b4a1eaefd91d35080831601eedf..0ec7663dfab636670a7411c2425e870734bd5ca2 100644 --- a/lite/api/paddle_api.cc +++ b/lite/api/paddle_api.cc @@ -237,6 +237,10 @@ void PaddlePredictor::SaveOptimizedModel(const std::string &model_dir, << "The SaveOptimizedModel API is only supported by CxxConfig predictor."; } +PaddlePredictor::~PaddlePredictor() { + lite::DeviceInfo::Global().CleanWorkspace(); +} + template std::shared_ptr CreatePaddlePredictor(const ConfigT &) { return std::shared_ptr(); diff --git a/lite/api/paddle_api.h b/lite/api/paddle_api.h index 42a4b2228b5dc007bc0d6053f15e843bd6343c8f..8f2d34001bf25e07402a8e3408296369f6baf574 100644 --- a/lite/api/paddle_api.h +++ b/lite/api/paddle_api.h @@ -118,7 +118,7 @@ class LITE_API PaddlePredictor { LiteModelType model_type = LiteModelType::kProtobuf, bool record_info = false); - virtual ~PaddlePredictor() = default; + virtual ~PaddlePredictor(); protected: int threads_{1}; diff --git a/lite/core/device_info.h b/lite/core/device_info.h index f3f10c2d5740d6e8cc7e219b8f0d9d9ff17a8496..3140ca09ab9d00c3ba347c9d811bb9a45de0fe27 100644 --- a/lite/core/device_info.h +++ b/lite/core/device_info.h @@ -77,6 +77,11 @@ class DeviceInfo { return reinterpret_cast(workspace_.mutable_data()); } bool ExtendWorkspace(size_t size); + bool CleanWorkspace() { + // workspace_.Resize({1}); + // workspace_.mutable_data(); + workspace_.clear(); + } private: int core_num_;