Solved TD-23319: Object reference counting memory leak

Report TD 5.x and 6.x bugs and possible workarounds.
wardies
Great Britain
Posts: 86
Joined: 21 Mar 2017, 10:44
Location: UK

TD-23319: Object reference counting memory leak

Post by wardies » 20 Dec 2016, 15:08

Hi all,

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.
chaining_memory_leak.zip
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 )
      .Equals(  )
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).

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).
MemoryLeakDemoScreenshot.png
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?

Thanks,
Marcel
You do not have the required permissions to view the files attached to this post.

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 3321
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: TD-23319: Object reference counting memory leak

Post by Dave Rabelink » 20 Dec 2016, 16:11

Tested this on TD 7.0.
Same leak and crash as on TD6.3.
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

wardies
Great Britain
Posts: 86
Joined: 21 Mar 2017, 10:44
Location: UK

Re: TD-23319: Object reference counting memory leak

Post by wardies » 21 Dec 2016, 10:05

Thank you for the confirmation, Dave.

jmgemperle
Netherlands
Posts: 2
Joined: 04 Dec 2019, 09:34
Location: HOLLAND

Re: TD-23319: Object reference counting memory leak

Post by jmgemperle » 06 Jan 2017, 13:35

This is now TD-23319

Cheers
JM

Return to “Bug Reports”

Who is online

Users browsing this forum: [Ccbot], aareon_orleans and 1 guest