Command creation with overwrite (prevention against endless loop by its recreation via trace) is affected by drastic mem-leak
PoC:
(and lets grow the mem-usage)
namespace eval A { proc test {} {puts test}; namespace export test }
proc recreate {args} { namespace eval ::B {
namespace import ::A::test };
trace add command ::B::test delete recreate
}
timerate { recreate; proc ::B::test {} {}; rename ::B::test {} } 10000
By regular deletion it'd restore everything back, but not by overwrite, that wins and this prevention causes that the new command overwrites the old at any cost without proper clean-up, no traces but also no deletion callback, no release for internal members, nothing excepting ckfree for cmdPtr.
I'd rather expects that 2nd run of trace is avoided and the command gets deleted and overwritten properly (and surely without the leak). Also if command gets restored again now via deletion callback, it shall win and attempt overwrite must cause something like "cannot create - existing command restored after deletion, avoid endless loop".