#1 2022-02-14 18:04:29

tbo
Member
Registered: 2015-04-20
Posts: 338

Using TAutoFree

I was looking around the mORMot2 mvc-blog example a bit and came across the use of TAutoFree. TAutoFree is nice to use. I remember (or I think I remember?) reading a warning that you should not use TAutoFree in current versions of Delphi (10.4+). Also not in conjunction with a variable IAutoFree. As a result, I rewrote an application to try ... finally. I'm a little confused. Have I misunderstood something?

With best regards
Thomas

Offline

#2 2022-02-14 19:55:00

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,333
Website

Re: Using TAutoFree

You need to use it either with a local variable, or a "with" statement.

Otherwise, the IAutoFree is released immediately, so it won't work as expected.

See https://blog.synopse.info/?post/2021/09 … ng-Changes

Offline

#3 2022-02-14 21:01:56

tbo
Member
Registered: 2015-04-20
Posts: 338

Re: Using TAutoFree

ab wrote:

You need to use it either with a local variable, or a "with" statement.

Otherwise, the IAutoFree is released immediately, so it won't work as expected.

See https://blog.synopse.info/?post/2021/09 … ng-Changes

Thanks for the clarification. Now I remember reading this blog post.

With best regards
Thomas

Offline

Board footer

Powered by FluxBB