exten => 9876,1,Answer()
same => n,Set(count=1)
same => n,While($[${count} < 1000])
; same => n,Set(GLOBAL(MYGLOBALVARIABLE_${count})=Variable count : ${count})
same => n,Set(GLOBAL(MYGLOBALVARIABLE_${count})=)
same => n,NoOp(${MYGLOBALVARIABLE_${count}})
same => n,Set(count=$[${count} + 1])
same => n,EndWhile
same => n,Hangup()
Memory affect when these values are assigned and when these values are removed from global variables.
The previous memory for the value would be freed, but it would still end up setting the variable to empty I believe thus using some memory - so it’s not running out of control.
As variables of type utilise system memory,i am of an opinion,discarding variables must result in free() call else it will keep building up. Let’s say,if we keep just declaring variables,it will utilise memory of variable type.
I shall check the code and reply accordingly.
It would be a nice optimization for it to completely destroy the variable if it does not, but in reality it still doesn’t matter that much. You would need to have a ton of variables in the first place to cause a problem which you can already do.