VirtualBox

Changeset 19017 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 20, 2009 8:12:58 AM (16 years ago)
Author:
vboxsync
Message:

Main: Fixed deletion of metrics. Not doing this leads to memory leaks & an lock
on the xml file of the VM (which produce other bugs). I reverted r45374 &
r45467 which where quick fixes for this only.

Location:
trunk/src/VBox/Main
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/MachineImpl.cpp

    r18818 r19017  
    27422742
    27432743    /* delete the settings only when the file actually exists */
    2744     lockConfig();
    27452744    if (isConfigLocked())
    27462745    {
     
    81088107        "Size of resident portion of VM process in memory.");
    81098108    /* Create and register base metrics */
    8110     IUnknown *objptr;
    8111 
    8112     ComObjPtr<Machine> tmp = aMachine;
    8113     tmp.queryInterfaceTo (&objptr);
    8114     pm::BaseMetric *cpuLoad = new pm::MachineCpuLoadRaw (hal, objptr, pid,
    8115                                              cpuLoadUser, cpuLoadKernel);
     8109    pm::BaseMetric *cpuLoad = new pm::MachineCpuLoadRaw (hal, aMachine, pid,
     8110                                                         cpuLoadUser, cpuLoadKernel);
    81168111    aCollector->registerBaseMetric (cpuLoad);
    8117     pm::BaseMetric *ramUsage = new pm::MachineRamUsage (hal, objptr, pid,
    8118                                                            ramUsageUsed);
     8112    pm::BaseMetric *ramUsage = new pm::MachineRamUsage (hal, aMachine, pid,
     8113                                                        ramUsageUsed);
    81198114    aCollector->registerBaseMetric (ramUsage);
    81208115
  • trunk/src/VBox/Main/PerformanceImpl.cpp

    r18487 r19017  
    492492        m.baseMetrics.begin(), m.baseMetrics.end(), std::bind2nd (
    493493            std::mem_fun (&pm::BaseMetric::associatedWith), aObject));
     494    /* Delete the content of the list as well */
     495    BaseMetricList::iterator it1 = it;
     496    for (;it1 != m.baseMetrics.end(); ++it1)
     497        delete *it1;
    494498    m.baseMetrics.erase(it, m.baseMetrics.end());
    495499    LogAleksey(("{%p} " LOG_FN_FMT ": after remove_if: m.baseMetrics.size()=%d\n", this, __PRETTY_FUNCTION__, m.baseMetrics.size()));
     
    508512        m.metrics.begin(), m.metrics.end(), std::bind2nd (
    509513            std::mem_fun (&pm::Metric::associatedWith), aObject));
     514    /* Delete the content of the list as well */
     515    MetricList::iterator it1 = it;
     516    for (;it1 != m.metrics.end(); ++it1)
     517        delete *it1;
    510518    m.metrics.erase(it, m.metrics.end());
    511519    //LogFlowThisFuncLeave();
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r18520 r19017  
    10931093    /* save the global registry */
    10941094    rc = saveSettings();
    1095     CheckComRCReturnRC (rc);
    1096 
    1097     /* Close settings file for this machine. */
    1098     rc = machine->unlockConfig();
    10991095
    11001096    /* return the unregistered machine to the caller */
  • trunk/src/VBox/Main/include/MachineImpl.h

    r18520 r19017  
    799799
    800800    HRESULT lockConfig();
    801 public: /* To have it available in VirtualBox::UnregisterMachine. */
    802801    HRESULT unlockConfig();
    803802
    804 protected:
    805803    /** @note This method is not thread safe */
    806804    BOOL isConfigLocked()
     
    11171115}
    11181116
     1117
    11191118#endif // ____H_MACHINEIMPL
    11201119/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette