All, We're currently finishing the development of an embedded Linux device which implements an AgentX sub-agent to populate our enterprise MIB OIDs, and we'd appreciate any help that you can give us to track down a small issue.
During long term soak testing, we've found that our subagent has a very slow memory leak (which would cause our device to run out of memory after roughly 100-130 days uptime). Profiling with valgrind suggests that the leak is caused in my function which adds a row to the event log table in our MIB (as shown below). The event log table is limited (elsewhere) to contain up to 128 entries (we remove the oldest rows if we go above 128 entries). void addEventToSNMPTable(int EventLogIndex, int EventSeverityCode, int EventTypeCode, int DeviceTypeCode, int PositionIndex, int DeviceSectionCode, long timeticks, std::string Date, std::string Time) { netsnmp_table_row *new_row = netsnmp_create_table_data_row(); netsnmp_table_row_add_index(new_row, ASN_ COUNTER, &EventLogIndex, sizeof(EventLogIndex)); netsnmp_set_row_column(new_row, COLUMN_EVENTINDEX, ASN_COUNTER, &EventLogIndex, sizeof(EventLogIndex)); netsnmp_set_row_column(new_row, COLUMN_EVENTSTICK, ASN_TIMETICKS, &timeticks, sizeof(timeticks)); netsnmp_set_row_column(new_row, COLUMN_EVENTDATE, ASN_OCTET_STR, Date.c_str(), strlen(Date.c_str())); netsnmp_set_row_column(new_row, COLUMN_EVENTTIME, ASN_OCTET_STR, Time.c_str(), strlen(Time.c_str())); netsnmp_set_row_column(new_row, COLUMN_EVENTSEVERITY, ASN_INTEGER, &EventSeverityCode, sizeof(EventSeverityCode)); netsnmp_set_row_column(new_row, COLUMN_EVENTSPECIFICTYPE, ASN_INTEGER, &EventTypeCode, sizeof(EventTypeCode)); netsnmp_set_row_column(new_row, COLUMN_EVENTDEVICETYPE, ASN_INTEGER, &DeviceTypeCode, sizeof(DeviceTypeCode)); netsnmp_set_row_column(new_row, COLUMN_EVENTPOSINDEX, ASN_INTEGER, &PositionIndex, sizeof(PositionIndex)); netsnmp_set_row_column(new_row, COLUMN_EVENTDEVICESECTION, ASN_INTEGER, &DeviceSectionCode, sizeof(DeviceSectionCode)); netsnmp_table_dataset_add_row(EventsSNMPTable, new_row); } And the exact valgrind output for a short run: ==30710== Thread 1: ==30710== 361 (24 direct, 337 indirect) bytes in 1 blocks are definitely lost in loss record 139 of 168 ==30710== at 0x4830698: calloc (vg_replace_malloc.c:711) ==30710== by 0x3D185: addEventToSNMPTable (int, int, int, int, int, int, long, std::string, std::string) (eventHistoryTable.cpp:89) ==30710== by 0x37B7B: readAndProcessMessageFromQueue() (snmpThreadQueue.cpp:118) (eventHistoryTable.cpp line 89 refers to "netsnmp_table_row *new_row = netsnmp_create_table_data_row();") I'm fairly certain there's nothing egregiously wrong in that function, and I cannot find anything in the Net-SNMP documentation that states how/if the new_row should be freed following a call to netsnmp_table_dataset_add_row(). Is there something I'm missing? Many Thanks, Mike Bend Pulse Power & Measurement Ltd. Registered in England & Wales. No 2963819. Registered office: 65 Shrivenham Hundred Business Park, Watchfield, Swindon, Wiltshire, SN6 8TY, UK ViaLite Communications (Pulse Power and Measurement Inc.). Office address: 1717 Pennsylvania Avenue NW, Suite 1025, Washington, DC 20006, USA ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Net-snmp-users mailing list Net-snmp-users@lists.sourceforge.net Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users