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

[MXNET-922] Fix memleak in profiler #12499

Merged
merged 2 commits into from
Sep 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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