未验证 提交 f50e701b 编写于 作者: X xujiaqi01 提交者: GitHub

fix memory leak in HogwildWorker (#19956)

fix memory leak in HogwildWorker,  whose ops are  explicitly deleted in destructor
上级 b8aff5e5
...@@ -151,7 +151,12 @@ class CPUWorkerBase : public DeviceWorker { ...@@ -151,7 +151,12 @@ class CPUWorkerBase : public DeviceWorker {
class HogwildWorker : public CPUWorkerBase { class HogwildWorker : public CPUWorkerBase {
public: public:
HogwildWorker() {} HogwildWorker() {}
virtual ~HogwildWorker() {} virtual ~HogwildWorker() {
for (OperatorBase* op : ops_) {
delete op;
}
std::vector<OperatorBase*>().swap(ops_);
}
virtual void Initialize(const TrainerDesc& desc); virtual void Initialize(const TrainerDesc& desc);
virtual void TrainFiles(); virtual void TrainFiles();
virtual void TrainFilesWithProfiler(); virtual void TrainFilesWithProfiler();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册