Arduino_SNMP
Arduino_SNMP copied to clipboard
Proper way to free AddXXXXHandler? Memory leak detected from SNMPAgent::buildOIDWithPrefix
When I use the snmp.removeHandler I am getting a memory leak. It appears to be coming from the following function call in the buildOIDWithPrefix function:
newOid = new SortableOIDType(temp);
The removeHandler must not be freeing the newOid from that call.
I dig some digging and it looks like you need to delete / free the Valuecallback after removing it. The removeHandler only removes it from the internal list. I had to modify the ~ValueCallback() to be virtual. Don't know if this is the correct way, but all the example just show how to add a callback and never remove them. I am doing some dynamic stuff and need to remove and add.