Apache + Delphi XE7 + Datasnap. Memory problems

Asked

Viewed 798 times

4

I developed a program with Apache, Delphi XE7 and Datasnap. My Apache httpd.exe consumes memory until it gives the "Out of Memory" message so I need to restart Apache.

I configured Servermodule (Firedac components, Mysql) and Webmodule to execute a simple query.

On the Client I have one DBGrid which displays the Query output

With Task Manager open and memory monitoring:

  • When connecting and disconnecting TSQLConnection or open and close the TClientDataSet memory increases.

What I’ve tried to do:

I executed the Pascal Analyzer looking for memory leaks but it’s ok, I tried to turn off the Keep Alive from Apache but it made no difference, I’ve used all kinds of Webmodule lifecycle (Session, Server and Invocation) but the problem persists.

From now on Thank you.

  • When did you use this command? Because it is in an application datasnap server, this can’t cause any problems when using a multi-layered application where each customer has their thread (RemoteDatamodule)?

2 answers

1

Try the code below, I believe it helps.

procedure TformPrincipal.LimpaMemoria;
var
   MainHandle : THandle;    
begin
   try
      MainHandle := OpenProcess(PROCESS_ALL_ACCESS, false, GetCurrentProcessID) ;
      SetProcessWorkingSetSize(MainHandle, $FFFFFFFF, $FFFFFFFF) ;
      CloseHandle(MainHandle) ;

   except
   end;

   Application.ProcessMessages;
end;

0

The above solution is very good, but to be used in the customer. On the server, if larger searches are made, it will be difficult to have memory for everyone.

On the server, prefer to use as little as possible. Turn off the options on FireDac who create cache of the information and change the pointer of the FireDac for unidirecional. Let the client cache the data (or transmit it via json or whatever).

Also make sure to use the method Release instead of the method free. Release removes the memory used by the cursor (and other memory eaters), while the free ignores all this.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.