Reduce snmpd memory usage. The route table can grow very large and existing code is a major performance problem since it wastes half of its memory and copies each time. 1. Grow expanding table by 1.5 rather 2x per step Perhaps the increment should just be PAGESIZE
2. Use realloc rather than copying, this allows for possible inplace growth and smart allocation. --- a/snmplib/container_binary_array.c 2008-09-04 11:47:25.000000000 -0700 +++ b/snmplib/container_binary_array.c 2008-09-04 12:26:14.000000000 -0700 @@ -357,19 +357,15 @@ netsnmp_binary_array_insert(netsnmp_cont /* * Table is full, so extend it to double the size */ - new_max = 2 * t->max_size; + new_max = t->max_size + t->max_size / 2; if (new_max == 0) new_max = 10; /* Start with 10 entries */ - new_data = (void *) calloc(new_max, t->data_size); + new_data = realloc(t->data, new_max * t->data_size); if (new_data == NULL) return -1; - if (t->data) { - memcpy(new_data, t->data, t->max_size * t->data_size); - SNMP_FREE(t->data); - } - t->data = (void**)new_data; + t->data = new_data; t->max_size = new_max; } ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/net-snmp-coders