Arduino_SNMP icon indicating copy to clipboard operation
Arduino_SNMP copied to clipboard

How to "Delete" a SNMPTrap object when allocated with the new SNMPTrap command

Open jamesarm97 opened this issue 2 years ago • 1 comments

I have a trap pointer declared with

trap = new SNMPTrap("public", SNMP_VERSION_2C);

and after sending the trap I want to delete the object so it doesn't take up memory and I will be calling the new command every time I want to send one with different information. I tried just using 'delete trap;' but that is causing a stack corruption or something and the ESP32 is restarting. Should this be feasible or am I looking at it wrong?

jamesarm97 avatar Feb 10 '23 21:02 jamesarm97

I am getting past the exception, but what I am seeing is only part of the memory is being freed when I delete the trap. So the memory leak will continue for every new trap created / freed until the memory is exhausted.

jamesarm97 avatar Feb 14 '23 19:02 jamesarm97