김성환 wrote: > > I am using the following function modified from the main function of > 'snmpget' program. >
Bear in mind that this code is a "use once" program. It doesn't necessarily try to tidy up cleanly, since all memory will be released automatically when the program exits. > When I call the functions infinitely, > > the memory size of the program grows. > A quick look at the code shows a couple of problems. You create a 'netsnmp_pdu' structure, which will be released automatically for a successful request. But if the request fails to be sent (status != STAT_SUCCESS), or if there is a problem populating the PDU (failures), then you return without releasing the PDU structure. You haven't said whether the request succeeds or not. > How can I solve the problem? > You might look at re-using the same netsnmp_session structure for each request, rather than re-creating it every time. Otherwise, your best bet is probably to try simplifying the code as much as possible (e.g. removing the "fix and retry" handling) until the leak goes away, or you're left with a minimal routine that still displays the problem. Dave ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Net-snmp-coders mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
