Memory leaks in Tokyo 10.2.3 for linux and RO 9.4.109.1375

linux-tokyo

(DonaldShimoda) #1

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.


(EvgenyK) #2

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


(DonaldShimoda) #3

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


(DonaldShimoda) #4

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.


(marc hoffman) #5

One way to find out?


(EvgenyK) #6

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


(EvgenyK) #7

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


(DonaldShimoda) #8

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


(DonaldShimoda) #9

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.


(DonaldShimoda) #10

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


(DonaldShimoda) #11

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


(EvgenyK) #12

thx. fixed.

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


(DonaldShimoda) #13

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


(EvgenyK) #14

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


(DonaldShimoda) #15

Use Unidac. Can test with trial?


(EvgenyK) #16

yep, unidac is ok


(DonaldShimoda) #17

Sent. thanks!


(DonaldShimoda) #18

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.


(DonaldShimoda) #19

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


(EvgenyK) #20

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)