[AGENT++] Memory leak inside a MibTable?
Petersen, Thorsten
Thorsten.Petersen at draeger.com
Wed Nov 10 11:26:45 CET 2004
Hello
I'm using a class derived from MibTable, e., g. "class Table : public MibTable",
After construction of an instance of that type I add the table to our MIB:
Table table = new table( oid,...) ;
getMib()->add( table ) ...
Shortly later, I defined the columns and use the add_col method of MibTable for instances of type derived from MibLeaf : "class Leaf : public MibLeaf"
Leaf tempLeaf = new Leaf( ... );
table->add_col(tempLeaf)
More column definitions follow , and I call the getMib()->init() and everything works fine. Note: As far as I understood, the column definitions are stored inside the "generator" member of class MibTable
class MibTable ...
MibTableRow generator;
But when I remove the table from the MIB with "getMib()->remove( oid )" where oid is the object id of the table mentioned above, the destructor of the class MibTable is called, but the leafs defining the columns are not destroyed. A look at the code of the library shows that the member "generator" is not used there.
MibTable::~MibTable()
{
if (index_struc) delete[] index_struc;
// listeners are just pointers, so do not delete them here
listeners.clear();
voters.clear();
}
Unfortunately, the destructor of class MibTableRow does nothing on the stored leaf pointers as well.
MibTableRow::~MibTableRow()
{
}
As a consequence, I'm removing the column definitions prior to the removal of the table, otherwise this will lead to a memory leak.
Table * table = static_cast<Table*>( ( getMib() )->get( oid ) );
if( table )
{
table->clear();
MibTableRow * columnTemplate = table->get_columns();
if(columnTemplate)
{
const int columnNumber = columnTemplate->size();
for( int i = columnNumber - 1; i >= 0 ; i-- )
{
columnTemplate->remove( i );
}
}
}
...
m_context->getMib() )->remove( oid )
I think, removing stored leafs could be done within the destructor of class MibTableRow as well. Are there reasons that prevent to delete the stored leafs inside the destructor of class MibTableRow?
With kind regards,
Thorsten Petersen
------------------------------------------------------------------
Important Note
This email and any attachment hereto are confidential and may contain trade
secrets or may be otherwise protected from disclosure. If you have received
it in error you are in notice of this fact. Please notify us immediately by
reply email and then delete this email and any attachment from your system.
Please understand that you are not allowed to copy this email or any
attachment hereto or disclose its contents to any other person. Thank you.
Wichtiger Hinweis
Diese E-Mail und etwaige Anlagen können Betriebs- oder Geschäftsgeheimnisse
oder sonstige vertrauliche Informationen enthalten. Sollten Sie diese E-Mail
irrtümlich erhalten haben, ist Ihnen dieser Umstand hiermit bekannt. Bitte
benachrichtigen Sie uns in diesem Fall umgehend durch Rücksendung der E-Mail
und löschen Sie diese E-Mail einschließlich etwaiger Anlagen von Ihrem
System. Diese E-Mail und ihre Anlagen dürfen weiterhin nicht kopiert oder an
Dritte weitergegeben werden. Vielen Dank.
------------------------------------------------------------------
Thorsten Petersen <thorsten.petersen(at)draeger.com>
Dräger Medical AG & Co. KGaA
Moislinger Allee 53-55
23542 Luebeck, Germany
------------------------------------------------------------------
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: InterScan_Disclaimer.txt
Url: http://lists.agentpp.org/pipermail/agentpp/attachments/20041110/1b5d9222/attachment.txt
More information about the AGENTPP
mailing list