diff --git a/paddle/fluid/framework/device_worker.h b/paddle/fluid/framework/device_worker.h index 34702df5291434d3e7a22e742bd84738bfec64bc..6164953083bf6ee1e1612829f6f89ac23dc02392 100644 --- a/paddle/fluid/framework/device_worker.h +++ b/paddle/fluid/framework/device_worker.h @@ -151,7 +151,12 @@ class CPUWorkerBase : public DeviceWorker { class HogwildWorker : public CPUWorkerBase { public: HogwildWorker() {} - virtual ~HogwildWorker() {} + virtual ~HogwildWorker() { + for (OperatorBase* op : ops_) { + delete op; + } + std::vector().swap(ops_); + } virtual void Initialize(const TrainerDesc& desc); virtual void TrainFiles(); virtual void TrainFilesWithProfiler();