Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
[MXNET-922] Fix memleak in profiler (v1.3.x) (#13120)
Browse files Browse the repository at this point in the history
* [MXNET-922] Fix memleak in profiler

* [MXNET-922] Use unique ptr default delete
  • Loading branch information
lebeg authored and szha committed Nov 7, 2018
1 parent 7f3b7b8 commit a5d1217
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/profiler/profiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Profiler::Profiler()
this->gpu_num_ = 0;
#endif

this->profile_stat = new DeviceStats[cpu_num_ + gpu_num_ + 2];
this->profile_stat = std::unique_ptr<DeviceStats[]>(new DeviceStats[cpu_num_ + gpu_num_ + 2]);
for (unsigned int i = 0; i < cpu_num_; ++i) {
this->profile_stat[i].dev_name_ = "cpu/" + std::to_string(i);
}
Expand Down
2 changes: 1 addition & 1 deletion src/profiler/profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ class Profiler {
/*! \brief filename to output profile file */
std::string filename_ = "profile.json";
/*! \brief profile statistics consist of multiple device statistics */
DeviceStats* profile_stat;
std::unique_ptr<DeviceStats[]> profile_stat;
/*! \brief Stats not associated directly with a device */
DeviceStats general_stats_;
/*! \brief Map category -> pid */
Expand Down

0 comments on commit a5d1217

Please sign in to comment.