Arduino_SNMP icon indicating copy to clipboard operation
Arduino_SNMP copied to clipboard

Proper way to free AddXXXXHandler? Memory leak detected from SNMPAgent::buildOIDWithPrefix

Open jamesarm97 opened this issue 10 months ago • 1 comments

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.

jamesarm97 avatar Dec 13 '24 16:12 jamesarm97

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.

jamesarm97 avatar Dec 13 '24 17:12 jamesarm97