Why does the REMOVE method of map container remove elements have memory leaks?

Try saving a temp local reference to found. And do remove first. Use the temp reference for your function and destroy it at the end. Once the function is over and local reference is gone, the memory should be released if that was the last thing referencing it.