OpenViBE forum
http://openvibe.inria.fr/forum/

Some memory leaks suggestions
http://openvibe.inria.fr/forum/viewtopic.php?f=2&t=5022
Page 1 of 1

Author:  mhardin [ Tue May 28, 2013 10:09 am ]
Post subject:  Some memory leaks suggestions

I have noticed a few memory leaks in the designer and some plugins. Herer is the list with some suggestions to correct them. I work with version14 but I checked if those issues were adressed in the last version.

1. openvibe-applications/designer/trunc/src/ovdCApplication.cpp : quitApplicationCB()
The commented lines at the end - after '// release the log manager and free the memory'- should be uncommented (bug it triggered fixed in next point)

2. Bug Fixed in last version : In openvibe-kernel-omk/trunc/src/openvibe-kernel/kernel/log/ovkCLogManager.cpp : removeListener()
If the pListener we want to remove is the last of the vector, we shouldn't do 'itLogListener++;'. Add a break to avoid it and I suggest we do a for loop instead of a while loop to avoid infinite recursion.
Code:
for (vector<ILogListener*>::iterator itLogListener=m_vListener.begin();itLogListener!=m_vListener.end();)
{
   if((*itLogListener)==pListener)
   {
      itLogListener=m_vListener.erase(itLogListener);
      l_bResult=true;
      break;
   }
   itLogListener++;
}


3. In openvibe-plugins/simple-visualisation/trunc/src/ovpCSignalDisplay/ovpCSignalDisplayView.cpp : ~SignalDisplayView()
The CSignalChannelDisplay objects referenced in the vector m_oChannelDisplay should be emptied - as we have 'm_oChannelDisplay[i] = new CSignalChannelDisplay(...)' and 'm_oChannelDisplay[i]->addChannel(i)' in init ()- and the bottom ruler destroyed - as we have 'm_pBottomRuler = new CBottomTimeRuler(...)' at the end of init().
Code:
std::vector < CSignalChannelDisplay* >::iterator it;
for (it=m_oChannelDisplay.begin();it!=m_oChannelDisplay.end();it++)
{
   (*it)->resetChannelList();
   delete (*it);
}
delete m_pBottomRuler;
m_pBottomRuler=NULL;


4. In openvibe-plugins/simple-visualisation/trunc/src/ovpCSignalDisplay/ovpCSignalDisplayLeftRuler.cpp : ~CSignalDisplayLeftRuler()
Remove the 'g_object_unref(m_pLeftRuler);'

5. openvibe-kernel-omk/trunc/src/openvibe-kernel/kernel/plugins/ovkCPluginModule.cpp
Add a ~CPluginModuleBase() virtual function to clear the m_vPluginObjectDescriptor - as we do pushbacks in getPluginObjectDescription().

6. openvibe-kernel-omk/trunc/src/openvibe-kernel/kernel/plugins/ovkCPluginManager.cpp : ~CPluginManager()
We need to empty the m_vPluginModule vector as it contains IPluginModules linked to CPluginModuleBase objects. Those objects should be uninitialized and deleted.
Therefore you can add at the end of the method the following instructions.
Code:
vector < IPluginModule* >::iterator k;
for(k=m_vPluginModule.begin(); k!=m_vPluginModule.end(); k++)
{
   (*k)->uninitialize();
   delete (*k);
}


7. In openvibe-kernel-omk/trunc/src/openvibe-kernel/kernel/visualisation/ovkCVisualisationTree.cpp : ~CVisualisationTree()
Add the following code right after the "TODO" to delete the CVisualisationWidget objects - that we add in 'addVisualisationWidget(...)' method.
std::map<OpenViBE::CIdentifier, OpenViBE::Kernel::IVisualisationWidget*>::iterator it;
Code:
for (it=m_vVisualisationWidget.begin();it!=m_vVisualisationWidget.end();it++)
{
   delete (*it).second;
}

Author:  jtlindgren [ Mon Jul 01, 2013 8:44 am ]
Post subject:  Re: Some memory leaks suggestions

Hi mhardin, many thanks for the suggestions. They had gone a bit under the radar for me, something wrong with my RSS. We'll try to incorporate them soon, not possibly to the next release (which is due this week), but to the SVN at least.


Cheers,
Jussi

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/