[AGENT++] should to be delete here?

Glenn Puchtel gpuchtel at gplicity.com
Wed Jan 19 13:03:55 CET 2005


Hello Jerry,

RequestList should be treated as an independent object and therefore
should be deleted independently, but ONLY after an object it was set in
(via set_request_list) is deleted! For example, a Mib object or any
object derived from Mib such as the SubAgentXMib.  See the following
comments in Mib.h:

	 * Note: The request list is NOT deleted by the receiver's
destructor.
	 *       This should be done outside class Mib

Also, see the following warning in the change log for v1.4.10b:

	Caution: RequestList must not be deleted before Mib. 
	This was not the case in earlier versions!

There have been (relatively) recent changes to the implementation of the
RequestList (v1.4.7d), however I also seem to recall that an update to
the examples also accompanied that change or shortly thereafter; it is
possible those changes to the examples somehow got lost.

Technically it would be a memory leak but in the case of the examples
the application is terminating so it would be reclaimed when the process
goes away.

Disclaimer: Obviously Frank and Jochen are the definitive authorities on
this matter so I defer the final say to them; however I can share with
you that I delete the RequestList in my agents (after) deleting the Mib
object... :-)

Regards,
Glenn

-----Original Message-----
From: agentpp-bounces at agentpp.org [mailto:agentpp-bounces at agentpp.org]
On Behalf Of OELoo Jerry
Sent: Tuesday, January 18, 2005 10:26 PM
To: AGENTPP at agentpp.org
Subject: [AGENT++] should to be delete here?

hi all
   some code from the agent++' examples:

   mib = new Mib();
 reqList = new RequestList();
Request* req;
 while (run) {
  req = reqList->receive(2);

  if (req) {
      mib->process_request(req);
  }
  else {
      mib->cleanup();
  }
 }
 delete mib;

from above code, we can see the "reqList" have been newed but it has not

been deleted distinctly ? this is why? 
is there memory leak here? or it has been deleted in internal?
thanks 
any hints will be appreciated !
 
Jerry

_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger:  http://messenger.msn.com/cn


_______________________________________________
AGENTPP mailing list
AGENTPP at agentpp.org
http://agentpp.org/mailman/listinfo/agentpp





More information about the AGENTPP mailing list