Recent

Author Topic: Memleak on fpjson example  (Read 1456 times)

soerensen3

  • Full Member
  • ***
  • Posts: 211
Memleak on fpjson example
« on: November 27, 2017, 05:05:29 pm »
Dear all,

the second example of the fpjson examples in the official doc causes a memleak on https://www.freepascal.org/docs-html/fcl/fpjson/index.html
If you compile with -gh you can see what I mean.

Code: Pascal  [Select][+][-]
  1.   D:=GetJSON('{ "Children" : ['+
  2.              '  { "Age" : 23, '+
  3.              '    "Names" : { "LastName" : "Rodriquez",'+
  4.              '                "FirstName" : "Roberto" }},'+
  5.              '  { "Age" : 20,'+
  6.              '    "Names" : { "LastName" : "Rodriquez",'+
  7.              '                "FirstName" : "Maria" }}'+
  8.              '  ]}');
  9.   E:=D.FindPath('Children[1].Names.FirstName');
  10.   Writeln(E.AsJSON);
  11.   FreeAndNil( D ); //<--- This line is missing!

In general I think the documentation should say something about the management of descendants of TJSONData (Or did I miss something?). As far as I know it  it is in the responsibility of the user to free the root element but child elements get freed automatically.

Is there some way you can suggest changes to the documentation?
Lazarus 1.9 with FPC 3.0.4
Target: Manjaro Linux 64 Bit (4.9.68-1-MANJARO)

GetMem

  • Hero Member
  • *****
  • Posts: 3758
Re: Memleak on fpjson example
« Reply #1 on: November 27, 2017, 05:11:04 pm »
Quote
Is there some way you can suggest changes to the documentation?
Mailing list, bugtracker.

soerensen3

  • Full Member
  • ***
  • Posts: 211
Re: Memleak on fpjson example
« Reply #2 on: November 27, 2017, 06:46:33 pm »
Lazarus 1.9 with FPC 3.0.4
Target: Manjaro Linux 64 Bit (4.9.68-1-MANJARO)

 

TinyPortal © 2005-2018