Memory leaks in Tokyo 10.2.3 for linux and RO 9.4.109.1375

Have two projects compiled with delphi for Linux64, both works fine but both have evident memory leaks. Same projects compiled for Delphi has no memory leaks. Can i send one of them if support find some problem in RO libs, maybe?

Best regards.

do you mean that projects if they are compiled for windows haven’t memory leaks but compiled for linux64 have memory leaks?

Yes, that was i mean. Complete project sent to support email.

Evgeny do you check the code?

Another doubt, according to this information:

http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Automatic_Reference_Counting_in_Delphi_Mobile_Compilers

On linux (or in ARC COMPILERS) must use DisposeOf in place of plain free.

I see the generated Intf Files still use .Free, by sample:

  if lFreeStream then begin
    __response.Free();
  end;

Im wrong?

Maybe that is causing the memory leaks.

Best regards.

One way to find out?

this code was used in _Async methods like Retrieve_Sum/Retrieve_GetServerTime.
I’m pretty sure that you don’t use them.

if you check sources, e.g. source\rtl\common, you will see that they mostly use Free method instead of DisposeOf.

From your link, they suggest to use this style:


Can you specify what exactly ROD objects causes memory leaks, pls?


We had some places in RO code where compiler said

H2593 Code has no effect. Compiler generated temporary variable is cleared instead

probably, compiler did memory leaks in these lines …

Will recheck those lines

I’ve fixed some lines in code. it will be in the next beta

Sadly is a headeache to find in delphi for linux compiler… I only can say the final result is memory wasting.

Are in release DA 1379?

Any chance to have acceso to pacthed files only between latest stable release and actual beta? Just suggestions.

Best regards.

Im checking the code of the beta 1379, seems like theres a bug here. Must be I but was changed to i, is ok?

Please confirm

Still cant fix the memory leak. Maybe the problem is on the manipulation of the json parser

soJsonData := TROJSONValue.Create(jdtObject);

Any special considerations/recomendations on the use of that class under ARC?

apk_fields := soJsonPackage.FindItem('pk_fields').ASArray;
apk_field_item := apk_fields.Items[posCampo].AsObject;

Best regards

thx. fixed.

this is pretty simple class and it shouldn’t cause any leaks.

Evgeny, i check everithing. Can send you the project to support? Is not a large project, pretty simple.

yes, you can.
pls check that it doesn’t use 3rd party libraries , like DevEx, etc

Use Unidac. Can test with trial?

yep, unidac is ok

Sent. thanks!

Have no news about that. Can you check?

Another questions or doubts.

In this case

var
  dw               : TDAWhereBuilder;
begin

        Contratos := SchemaGetDataset(lConexionFacturar, ServerDataModule.Schema, nme_contratos, fld_contratos_fecha, True);
        dw        := Contratos.DynamicWhere;

must be dw be defined as weak reference in Delphi ARC Compiler?

i have a lot of that kind of shorcuts references, maybe this is causing leaks?

Best regards.

I find the reason for memory leak (on delphi for linux compiler)

var
  soJsonData        : TROJSONValue;
  soJsonPackage     : TROJSONObject;
  apk_fields        : TROJSONArray;

  soJsonData   := TROJSONValue.Create(jdtObject);
(soJsonData.RefCount = 1)
  soJsonPackage     := soJsonData.AsObject;
(soJsonPackage.refCount = 2) (???)
 apk_fields := soJsonPackage.FindItem('pk_fields').ASArray;
   (apk_fields.refCount = 2) (???)

Im wrong? or something is very wrong with the library?

Best regards

Delphi compiler should recognize local variables like dw and it should decrease refcount at exiting from this method, however you can assign nil manually when this variable isn’t required.

btw, have you called table.DynamicWhere.Clear; or table.DynamicWhere.Expression.Free; before assigning new expression into table.DynamicWhere.Expression ?

I think, these is no memory leak present: one reference is stored in TROJSONValue.FObject and second one - in soJsonPackage (local variable)