I've written a Windows service which consumes an inbound data stream and
sends out SNMP traps using netsnmp.lib.

During service initialization I call:
snmp_sess_init(&session);
session.version = SNMP_VERSION_1;
init_snmp("snmpapp");
... and set session.peername, session.community, and session.community_len
SOCK_STARTUP;
setup_engineID(NULL, NULL);
snmpv3_generate_engineID(&session.contextEngineIDLen);
ss = snmp_add(&session, netsnmp_transport_open_client("snmptrap",
session.peername), NULL, NULL);

At service termination I call:
snmp_close(ss);
snmp_shutdown("snmpapp");
SOCK_CLEANUP;


But while the service is running, it is constantly building new PDU's and
calling snmp_send(ss, pdu) passing the same session pointer created at
initialization. I have found that every call to snmp_send() allocates a
little more memory and never releases it. I confirmed this by commenting out
the call to snmp_send() and adding a call to snmp_free_pdu(pdu). In other
words, my program just builds PDU's and then throws them away. In this setup
(obviously just for testing) memory use stays perfectly flat.

My question is: is there a reason why snmp_send() is leaking memory, how do
I fix it, or should I be using a different function in this scenario?

Thanks in advance,
Adam
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to