new.gif NEW in 3ds Max 9: The dotNetMXSValue value class holds another value. The dotNetMXSValue can be assigned to .net objects. A "proxy" DotNet value is actually stored to the DotNet object, and that proxy points back to the dotNetMXSValue.

As long as the DotNet object holds the proxy value, the dotNetMXSValue and the value it holds are protected from garbage collection.



a = color 10 20 30 --MAXScript color value

b = dotNetMXSValue a --DotNet value holding the MAXScript value

tv = dotnetobject "treeview" --DotNet TreeView control

tv.tag = b --The tag is set to the color


a=b=undefined --Both a and b are set to undefined

gc() --and manual garbage collection is requested


--BUT the color value and dotNetMXSValue protected are from

--collection because the treeview instance holds

--the dotNetMXSValue proxy!


tv = undefined --assign undefined to the treeview variable

gc() --and request garbage collection again


--This time both the color value and the dotNetMXSValue are not

--protected from collection


Note that the above garbage collection may not delete the color value and the dotNetMXSValue because the DotNet garbage collector has not deleted the treeview and freed its values yet. One can force manual garbage collection of DotNet:


dgc = dotnetclass "system.gc"


gc() -- color value and dotNetMXSValue collected


See also

DotNet In MAXScript