DynamoDS/Dynamo — pull request #2062 by ke-yu (2014-07-30 07:35:57+00:00)
Title: Decrease reference count for the return value from function pointer evaluator

This pull request is to fix a memory leak issue in the VM. It was reported in DataBridge branch but could be reproduced by a pure language test case:
```
def foo(xs:var[]..[])
{
return = xs;
}

def DoNothing(param: var[]..[])
{
return = [Imperative]
{
_params = {};
_params[0] = param;
return = Evaluate(foo, _params, true);
}
}

xs = 0..10000;

[Imperative]
{
while (true)
{
xs = DoNothing(xs);
}
}
```
The problem here is ``Evaluate()`` consequently uses function pointer evaluator to call ``foo()`` implicitly, so the reference count of the return value from ``foo()``, normally is ``RX`` register, is not set to 0.

When the return value of ``Evaluate()`` is returned from language block, the last two instructions are
``push _rx; pop _rx``, here ``pop`` instruction will copy old memory to a new old, and it is a register, the old one is not released (the behavior here is incorrect. [A bug](http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-4074) is logged to trace the problem).

Run language test cases to ensure no regression.

Verified on DataBridge branch, no significant memory leak any more.