0neblock / Arduino_SNMP

SNMP Agent built with Arduino
MIT License
77 stars 30 forks source link

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

Open jamesarm97 opened 1 year ago

jamesarm97 commented 1 year ago

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 commented 1 year ago

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.