Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: DataSnap Consumption Memory Server Side...



Permlink Replies: 1 - Last Post: Mar 2, 2016 6:45 AM Last Post By: lucas chagas
Thiago Silva


Posts: 37
Registered: 12/20/04
DataSnap Consumption Memory Server Side...
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 20, 2016 4:27 AM
Hello Everyone,

We have a 32 bits DataSnap/DBExpress app server using 5 DSServerModule and we identified some memory leak called by client side (VCL 32 Bits) and when the server process in the Windows Server 2008 R2 reaches near of 1.5 GB RAM the following message error is showing up: "Remote Error: Out Of Memory". We know that memory leak is a big fault but why 1.5 gb consumption ram memory to occours the remote error? Consider that we have 300 users connected to the server without memory leak maybe reach the same memory consumption and what to do to deal with?

We are making mistakes? Please help us! Below the code to figure the memory leak purposeful to undesrtand the case:

var cds: TClientDataSet;
dsp: TDSProviderConnection;
I: Integer;
begin
inherited;
for I := 1 to 10000 do
begin
dsp := TDSProviderConnection.Create(Self);
dsp.SQLConnection := DMMain.DSServer;
cds := TClientDataSet.Create(Self);
dsp.ServerClassNAme := 'TDSSMCad';
cds.ProviderName := 'dspProdutos';
cds.CommandText := 'SELECT * FROM PRODUTOS';
cds.RemoteServer := dsp;
cds.Open;
end;
Best regards,

Thiago.
lucas chagas

Posts: 6
Registered: 2/19/08
Re: DataSnap Consumption Memory Server Side...
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 2, 2016 6:45 AM   in response to: Thiago Silva in response to: Thiago Silva
Thiago,

Looking closely the code you posted, it shows that you create some components (DSP and CDS) but you not destroy them.
If you create 10000 times the two objects and not destroy them, you use the memory without releasing it.

Resuming, if you want to create, use and release, the code below would give you a simple example.

procedure TesteObjetos();
var
ds: TClientDataSet;
dsp: TDSProviderConnection;
i: Integer;
begin
inherited;
for I := 1 to 10000 do
begin
dsp := TDSProviderConnection.Create(Self); // create
try
dsp.SQLConnection := DMMain.DSServer;
dsp.ServerClassNAme := 'TDSSMCad';

cds := TClientDataSet.Create(Self); // create
try
cds.ProviderName := 'dspProdutos';
cds.CommandText := 'SELECT * FROM PRODUTOS';
cds.RemoteServer := dsp;
cds.Open;

<do what i need to do>
finally
cds.close;
cds.disposeof; // destroy
cds := nil; // clean the var
end;
finally
dsp.disposeof; // destroy
dsp := nil; // clean the var
end;
end;
end;

Thiago Silva wrote:
Hello Everyone,

We have a 32 bits DataSnap/DBExpress app server using 5 DSServerModule and we identified some memory leak called by client side (VCL 32 Bits) and when the server process in the Windows Server 2008 R2 reaches near of 1.5 GB RAM the following message error is showing up: "Remote Error: Out Of Memory". We know that memory leak is a big fault but why 1.5 gb consumption ram memory to occours the remote error? Consider that we have 300 users connected to the server without memory leak maybe reach the same memory consumption and what to do to deal with?

We are making mistakes? Please help us! Below the code to figure the memory leak purposeful to undesrtand the case:

var cds: TClientDataSet;
dsp: TDSProviderConnection;
I: Integer;
begin
inherited;
for I := 1 to 10000 do
begin
dsp := TDSProviderConnection.Create(Self);
dsp.SQLConnection := DMMain.DSServer;
cds := TClientDataSet.Create(Self);
dsp.ServerClassNAme := 'TDSSMCad';
cds.ProviderName := 'dspProdutos';
cds.CommandText := 'SELECT * FROM PRODUTOS';
cds.RemoteServer := dsp;
cds.Open;
end;
Best regards,

Thiago.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02