Freeing ItemsMenu

Applies to:Fast Math Parser
Freeing Items that are no longer needed
Remarks
When we define an Item for temporary use, it's important to release it afterwards when no longer needed. This frees up the memory allocated to the item. #c For x = 1 To 1000 VariableX.SetVariableValue(x) Answer = Answer + Expr.Evaluate() Next Expr.Release() VariableX.Release() #c Note: When a uCalc object goes out of scope, the object is destroyed, however, internally within uCalc the Item remains alive. To release an Item, you must explicitely call Release. It is typically not necessary to release an entire uCalc instance each time. Releasing and redefining an entire uCalc instance is a relatively slow process (if you're in a tight loop). Instead, release just the temporary items you have defined. Or you may group temporary items into a namespace, and delete that. #c Dim TempNamespace = uc.NameSpaceSet("Temp") Dim VariableX = uc.DefineVariable("x") Dim Expr = uc.Parse("x^2 + 2*x + 5") For x = 1 To 1000 VariableX.SetVariableValue(x) Answer = Answer + Expr.Evaluate() Next TempNamespace.Release() ' Releaseses both Expr and VariableX Expr.Release() VariableX.Release() #c
Prev | Next