Does asterisk free memory when assigned values of global variables are emptied


#1

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.


#2

I don’t think the code would free the variable in that case, it would just get set to an empty value.


#3

Thank you !

Is there any way we can delete the global variable we have defined in dailplan ?


#4

What is the real problem that you are trying to solve?


#5

It should free memory else it will keep building up variables with no values exhausting the system resource. Are you sure,its not doing?


#6

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.


#7

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.


#8

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.