Some memory leaks suggestions

Tinkering with OpenViBE core: kernel/, modules/, toolkit/ etc
Post Reply
Posts: 2
Joined: Mon Mar 25, 2013 1:42 pm

Some memory leaks suggestions

Post by mhardin »

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: Select all

for (vector<ILogListener*>::iterator itLogListener=m_vListener.begin();itLogListener!=m_vListener.end();)
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 = new CSignalChannelDisplay(...)' and 'm_oChannelDisplay->addChannel(i)' in init ()- and the bottom ruler destroyed - as we have 'm_pBottomRuler = new CBottomTimeRuler(...)' at the end of init().

Code: Select all

std::vector < CSignalChannelDisplay* >::iterator it;
for (it=m_oChannelDisplay.begin();it!=m_oChannelDisplay.end();it++)
	delete (*it);
delete m_pBottomRuler;
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: Select all

vector < IPluginModule* >::iterator k;
for(k=m_vPluginModule.begin(); k!=m_vPluginModule.end(); k++)
	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: Select all

for (it=m_vVisualisationWidget.begin();it!=m_vVisualisationWidget.end();it++)
	delete (*it).second;

Posts: 775
Joined: Tue Dec 04, 2012 3:53 pm
Location: INRIA Rennes, FRANCE

Re: Some memory leaks suggestions

Post by jtlindgren »

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.


Post Reply