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:
Code: Select all
Set nValue = CalculatorWithStartValue( 31 )
.Plus( 19 )
.Plus( -8 )
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?