Home > Back-end >  DataSanp TFDJSONDataSets
DataSanp TFDJSONDataSets

Time:09-28

The function TServerMethods. GetData (SQLStr: String) : TFDJSONDataSets;
Var
Q: TFDQuery;
The begin
Q:=TFDQuery. Create (nil);
Q.C onnection:=DataM. FDCon;
Try
Q.O pen (SQLStr);
Result:=TFDJSONDataSets. Create;
//Add the departments dataset
TFDJSONDataSetsWriter. ListAdd (Result, Q);
The finally
Q.F ree; ????? With the extraction times wrong data, without memory leaks
The end;
The end;
Environment: XE6
I look at the Data. The unit FireDACJSONReflect
Destructor TFDJSONDataSetsBase. Destroy;
The begin
If FOwnsDataSets and (FDataSets & lt;> Nil) then
While FDataSets. Count & gt; 0 do
The begin
{$# IFNDEF NEXTGEN}
FDataSets [0]. Value. Free; ????? This seems didn't release the DATASET
{$ENDIF}
FDataSets. Delete (0);
The end;
FDataSets. Free;
Inherited;
The end;

CodePudding user response:

I met a similar problem, the release of the server object

The function TdssmServerMethods. GetDataR (const ASQLStr: string) : TDBXReader;
Var
ADBXCommand: TDBXCommand;
The begin
Result:=nil;
If not sqlconMethods. Connected then
SqlconMethods. Open;
ADBXCommand:=sqlconMethods DBXConnection. CreateCommand;

Try
ADBXCommand. Text:=ASQLStr;
ADBXCommand.Com mandType:=TDBXCommandTypes. DbxSQL;//'Dbx. SQL'
Result:=aDBXCommand. ExecuteQuery;
Except,
SqlconMethods. Close;//this is returned to the client a TDBXReader instance, estimated TDBXReader is long connection, so can't close the connection
The end;
The end;

The aDBXCommand cannot release here,
Also can't so
The finally
SqlconMethods. Close;

Is said to be the client calls this method, the client instance TDBXReader released, the server automatically release,,,,,,,

CodePudding user response:

You define methods:
The function TServerMethods. GetData (SQLStr: String) : TFDJSONDataSets;
Q: TFDQuery;
Not any release, because also in passing data, released, pass?

DataSanp default automatically release here,

CodePudding user response:

The finally
Q.F ree; ????? With the extraction times wrong data, without memory leaks
After closing the client, and then quit the server so memory leaks
  • Related