Here is a simple demo I put together that exemplifies the problem I'm
seeing. If you run this code as-is, memory use will increase indefinately.
However, if you take out the snmp_send() call and just call snmp_free_pdu(),
memory use will remain perfectly flat. I should also mention that my
netsnmp.lib is built with HAVE_WIN32_PLATFORM_SDK and
NETSNMP_DISABLE_MIB_LOADING.

#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <conio.h>
#include <stdio.h>
void test_send(netsnmp_session *ss);
void main()
{
    netsnmp_session session, *ss;
    session.peername = "192.168.1.135";
    session.community = (u_char *) "public";
    session.community_len = 6;
    bool sending = true;
    // Initialization
    snmp_sess_init(&session);
    session.version = SNMP_VERSION_1;
    init_snmp("snmpapp");
    SOCK_STARTUP;
    ss = snmp_add(&session,
                  netsnmp_transport_open_client("snmptrap",
session.peername),
                  NULL, NULL);

    // Main loop
    printf("Sending traps. Press any key to stop.\n");
    while(sending) // this is the main loop
    {
        if (_kbhit()) sending = false;
        test_send(ss);
        printf(".");
    }
    // Cleanup
    snmp_close(ss);
    snmp_shutdown("snmpapp");
    SOCK_CLEANUP;
    return; // exit
}
void test_send(netsnmp_session *ss)
{
    netsnmp_pdu    *pdu;
    pdu = snmp_pdu_create(SNMP_MSG_TRAP);
    // On error, we must free the PDU ourselves
    if (snmp_send(ss, pdu)) {
        snmp_free_pdu(pdu);
        printf("\nERROR");
    }
}
------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to