#1 2018-03-14 17:01:18

MikaK
Member
Registered: 2016-11-09
Posts: 14

Direct assign of _Obj result to dovariant value

Hi,
Look's like this is causing memory leak (6 x ansistring and 2 x unknown)

var
  src,a: Variant;
begin
  TDocVariant.New( src );
  src.text := 'something';
  src.attachments := _Obj(['field1','abc','field2','def','field3','foofoo']);
end;

And this is not

var
  src,a: Variant;
begin
  TDocVariant.New( src );
  src.text := 'something';
  a := _Obj(['field1','abc','field2','def','field3','foofoo']);
  src.attachments := a;
end;

Is this supposed to be like this?
(Sorry I haven't yet figured out of all fine details of TdocVariant, even we use it quite much)

mika

Offline

#2 2018-03-14 19:02:30

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

Re: Direct assign of _Obj result to dovariant value

There is something wrong on your sidE.

Not able to reproduce with the following code:

program ProjectDocVarLeak;

{$APPTYPE CONSOLE}

uses
  FastMM4, // with EnableMemoryLeakReporting;FullDebugMode
  SynCommons,
  SysUtils;

procedure test;
var
  src: Variant;
begin
  TDocVariant.New( src );
  src.text := 'something';
  src.attachments := _Obj(['field1','abc','field2','def','field3','foofoo']);
end;

begin
  test;
end.

Offline

#3 2018-03-15 08:33:39

MikaK
Member
Registered: 2016-11-09
Posts: 14

Re: Direct assign of _Obj result to dovariant value

Yes!
I opened my D2007 virtual and had no problems. This memory leak occurs with D10.1 Berlin and D10.2 Tokyo update 2.
In D10.1 I tried with and without fastmm4.

Offline

#4 2018-06-16 21:24:09

jairgza
Member
Registered: 2015-01-15
Posts: 10

Re: Direct assign of _Obj result to dovariant value

The same happens to me, I use  ReportMemoryLeaksOnShutdown := True;

This causes MemoryLeak

v := _Obj(['token','123']);
v.document := _Obj(['ref', 'abc']);


--This works ok--

v := _Obj(['token','123',  'document',_Obj(['ref','abc']) ]);

--This works ok--

v := TDocVariant.New();
v.token := '123';
v.document := TDocVariant.New();
v.document.ref := 'abc';

Testing latest mormot sources, Windows10 , Delphi XE7

Offline

Board footer

Powered by FluxBB