First, a bit of background.
We are making more use of TD functional classes every day as our products grow and we get inspired by other language styles. Specifically, we are expanding our use of functional classes to allow things like method chaining (e.g. jQuery, LINQ) as this helps expedite development as well as improving readability and maintainability.
With that in mind, we have hit a bit of an issue with TD's runtime reference counting for objects that allows us to cause a memory leak or (in TD6.3 SP1, if we try and stop the leak) crash the runtime.
Attached is a repro case with further info in the Application Description.
Essentially we are seeing the memory leak when we have a helper function that returns a new object and then we go on to use chaining to call methods on that object. An overly-simplified example would be a calculator that allows us to add numbers together and get the result:
In TD4.2 and TD6.3, the memory leaks seen pressing the 1st button can be avoided (at least apart from a small initial leak) for the simple case by using a static variable in the helper function (press the 2nd button).
Code: Select all
Set nValue = CalculatorWithStartValue( 31 ) .Plus( 19 ) .Plus( -8 ) .Equals( )
However, if we check the "2x new Calculators in one expression" checkbox then pressing the 2nd button causes the TD6.3 runtime to crash (or it goes into some undetermined state).
Is anyone able to confirm if the leak/crash issue is present in TD7.x too?
Might this be fixable in the TD6.3 build, or is there another workaround for the helper function that doesn't leak memory or confuse the runtime?