Does exist a simple way to remove variables?

Maybe somebody know a simple way to remove variables what was created during the script testing for example if you create rollout

rollout rl_test "Some Rollout" width:100 height:100
  checkbutton myButton "My Button" width:80 height:24
createDialog rl_test

if I execute code bellow before rollout is created


then I get
-- Unknown property: "myButton" in undefined
and this is fine because max doesn't know about such a rollout and button

but after rollout was created it always returns some value even if rollout was closed. Maybe are some smart way to clear this data from Max memory without restarting Max.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miledrizk's picture


It's an old post i know, but in case someone else has this problem and came to this thread.

To remove a global variable, you need to use globalvars.remove

for example if your global variable is called my_number, then to remove it you just type

globalvars.remove "my_number"

Anubis's picture

see globalVars Structure

Free() Method is nice to clean up memory BUT it NOT revome global variables(!), it just reinit their value. For example:

str = "The big power mean big responsibility"
free str
str == "" --> true
str == undefined --> false

You can check in the help for globalVars Structure but read carefully all the warning notes.

In the best case, a.k.a. good practice, use only Local variables.


my recent MAXScripts RSS (archive here)

kproudfoot_zynga's picture

You can also try free()

This has been in Max since version 2009, but they say it was undocumented until version 2012.

Free() Method

The free() method has been implemented since 3ds Max 9 but has remained undocumented. This method frees the memory used by the value without waiting for a garbage collection to occur. It is implemented for the following classes:

String Value
StringStream Value
FileStream Value
BitMap Value
Array Value
BitArray Value
Mesh Value

Principal Technical Artist - Zynga, Inc.

jos's picture

you can simply type this

you can simply type this line

rl_test = undefined
Arahnoid's picture

Thanks Jos For rollout

Thanks Jos
For rollout elements it will work perfect :)
However for another kind of variables what are cashed will be more work to undefine all of them.

jos's picture

dont think it's possible

dont think it's possible without restart max. you can try yo run the garbage collector. (Maxscript help : Manual Garbage Collection) but it doesnt clear variables in use..

Arahnoid's picture

gc() - doesn't help

You are right garbage collect doesn't help :(
any way thank you for help :) at list now I know how to destroy variables in rollout :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.