From 51db7d63c10839584bbc13387999b310ff5f7602 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Wed, 6 Jan 2016 21:37:45 +0100 Subject: [PATCH] plug a memleak --- src/surf/host_interface.cpp | 4 ++++ src/surf/vm_hl13.cpp | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/surf/host_interface.cpp b/src/surf/host_interface.cpp index 4585220e24..203bedeea4 100644 --- a/src/surf/host_interface.cpp +++ b/src/surf/host_interface.cpp @@ -118,6 +118,10 @@ Host::Host(simgrid::surf::Model *model, const char *name, xbt_dict_t props, lmm_ Host::~Host() { xbt_assert(currentlyDestroying_, "Don't delete Hosts directly. Call destroy() instead."); + delete p_cpu; + // FIXME: VM plays strange games, leading to segfaults if I do the expected thing of next line + // delete p_netElm; + delete p_storage; } /** @brief Fire the require callbacks and destroy the object * diff --git a/src/surf/vm_hl13.cpp b/src/surf/vm_hl13.cpp index 3310186c86..d326759f15 100644 --- a/src/surf/vm_hl13.cpp +++ b/src/surf/vm_hl13.cpp @@ -177,8 +177,8 @@ VMHL13::VMHL13(VMModel *model, const char* name, xbt_dict_t props, sg_host_t hos * free callback for the network resource object. The network resource object * is still used by the physical machine. */ p_netElm = new RoutingEdgeWrapper(host_PM->p_netcard); - sg_host_t host = sg_host_by_name_or_create(name); - host->p_netcard = p_netElm; + sg_host_t host_VM = sg_host_by_name_or_create(name); + host_VM->p_netcard = p_netElm; p_currentState = SURF_VM_STATE_CREATED; @@ -186,7 +186,7 @@ VMHL13::VMHL13(VMModel *model, const char* name, xbt_dict_t props, sg_host_t hos // Roughly, create a vcpu resource by using the values of the sub_cpu one. CpuCas01 *sub_cpu = static_cast(host_PM->p_cpu); - p_cpu = surf_cpu_model_vm->createCpu(host, // the machine hosting the VM + p_cpu = surf_cpu_model_vm->createCpu(host_VM, // the machine hosting the VM sub_cpu->getSpeedPeakList(), // host->power_peak, sub_cpu->getPState(), 1, // host->power_scale, -- 2.20.1