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

Commit

Permalink
WIP: Fix memleak in profiler
Browse files Browse the repository at this point in the history
  • Loading branch information
KellenSunderland committed Sep 10, 2018
1 parent d410de1 commit 0a44f22
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[], std::default_delete<DeviceStats[]>> profile_stat;
/*! \brief Stats not associated directly with a device */
DeviceStats general_stats_;
/*! \brief Map category -> pid */
Expand Down

0 comments on commit 0a44f22

Please sign in to comment.