From: Nicholas L. Nigay (nnigay@cboss.ru)
Date: Thu Mar 21 2002 - 01:13:16 PST
There are a few amount of memory new()-ed in LoadConfigFile().
But not all of them are freed.
It causes memory leak each time config is re-readed.
in CflowdConfig.cc ( or CflowdConfig.cc.in if you prefer ):
// ---------------- wrong : causes memory leak ------------
void CflowdConfig::Clear()
{
if (this->_ciscoMap.size() > 0)
this->_ciscoMap.erase(this->_ciscoMap.begin(),this->_ciscoMap.end());
if (this->_portList.size() > 0)
this->_portList.erase(this->_portList.begin(),this->_portList.end());
if (this->_collectorMap.size() > 0)
this->_collectorMap.erase(this->_collectorMap.begin(),
this->_collectorMap.end());
return;
}
// ----------------- looks correct : no memory leak ---------------
void CflowdConfig::Clear()
{
if (this->_ciscoMap.size() > 0) {
for (CflowdCiscoMap::iterator iterCisco = this->_ciscoMap.begin();
iterCisco != this->_ciscoMap.end(); iterCisco++ ) {
delete( (*iterCisco).second );
}
this->_ciscoMap.erase(this->_ciscoMap.begin(),this->_ciscoMap.end());
}
if (this->_portList.size() > 0)
this->_portList.erase(this->_portList.begin(),this->_portList.end());
if (this->_collectorMap.size() > 0) {
for (CflowdCollectorMap::iterator iterCollct =
this->_collectorMap.begin();
iterCollct != this->_collectorMap.end(); iterCollct++ ) {
delete( (*iterCollct).second );
}
this->_collectorMap.erase(this->_collectorMap.begin(),
this->_collectorMap.end());
}
return;
}
PS: Please, let me know if i was wrong.
-- Good luck! Nicholas L. Nigay
This archive was generated by hypermail 2.1.4 : Mon Mar 25 2002 - 11:16:01 PST