nwangtw commented on a change in pull request #3248: STREAMCOMP-2724: TMaster
migrated to mostly use smart pointers instead of manual memory management
URL: https://github.com/apache/incubator-heron/pull/3248#discussion_r279890296
##########
File path: heron/stmgr/src/cpp/manager/instance-server.cpp
##########
@@ -133,49 +135,50 @@ InstanceServer::~InstanceServer() {
Stop();
// Unregister and delete the metrics.
for (auto immIter = instance_metric_map_.begin();
- immIter != instance_metric_map_.end(); ++immIter) {
+ immIter != instance_metric_map_.end();) {
sp_string instance_id = immIter->first;
+
for (auto iter = instance_info_.begin(); iter != instance_info_.end();
++iter) {
if (iter->second->instance_->instance_id() != instance_id) continue;
InstanceData* data = iter->second;
Connection* iConn = data->conn_;
if (!iConn) break;
sp_string metric_name = MakeBackPressureCompIdMetricName(instance_id);
metrics_manager_client_->unregister_metric(metric_name);
- delete immIter->second;
}
+
+ immIter = instance_metric_map_.erase(immIter);
Review comment:
maybe put this line in the for loop? I am afraid someday I cant help adding
the "missing" immIter++. :)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services