Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Memory usage from Remote Data Modules

36 views
Skip to first unread message

Ricardo Carmo

unread,
Jul 1, 2008, 8:18:12 AM7/1/08
to
Hi all.

I'm using a Remote Data Module in a Apache Server, and clients using
TWebConnection.
My RDM is a .exe. Everthing is ok, but I have a little problem:

My app clients are connecting with the RDM in 1 minute intervals to perform
some operations.
In each connection, the RDM consumes a amount X of memory, and does not free
that memory after disconnecting.

The executable process stays running all the time and the memory usage is
always increasing.
I wrote an FreeAndNil(self) (self=RDM) but does not matter.

What is wrong?

Sorry for my bad english, and thanks in advance.

Ricardo Carmo


Ricardo Carmo

unread,
Jul 1, 2008, 8:47:59 AM7/1/08
to
Missing information:
Delphi 7, Win2K server

Ricardo Carmo


"Ricardo Carmo" <nwl...@yahoo.com.br> escreveu na mensagem
news:486a...@newsgroups.borland.com...

PhilDGS

unread,
Jul 1, 2008, 2:12:03 PM7/1/08
to
Hi Ricardo;

There can be lots of circunstances ...
Are you creating RDM in your own code?. How?. In the main thread?.
What kind of components are you creating for each RDM instance?. Are you
cleanning those components after using them?.

Phil.


Ricardo Carmo

unread,
Jul 1, 2008, 6:09:18 PM7/1/08
to
Hello Phil.

> Are you creating RDM in your own code?. How?. In the main thread?.

No. I'm using a "blank" RDM, created by Wizard in
File->New->Other->Multitier->Remote Data Module.


> What kind of components are you creating for each RDM instance?. Are you
> cleanning those components after using them?.

I'm using the components that I need: IBDatabase, IBQuerys,
DataSetProviders.
Some components are created in design time, others in runtime.
And yes, I'm cleanning those components. What I did was:

a) My RDM have a method "CloseMyConnection" executed by the client app.
This method perform a RDM.Components[0].Free while ComponentCount>0;
After all, this method perform a FreeAndNil(self) where self is the RDM.
b) The client app perform a RDM.Disconnect.

In this time, all works fine, but the executable process stays running, and
the
allocated memory does not decrease.

Any ideas?
Thanks.


"PhilDGS" <phi...@hotmail.com> escreveu na mensagem
news:486a...@newsgroups.borland.com...

PhilDGS

unread,
Jul 1, 2008, 7:55:16 PM7/1/08
to
Hi Ricardo;

Try to destroy RDM from outside of it (same level in where you created it),
and see what happen.

Phil


Ricardo Carmo

unread,
Jul 2, 2008, 7:33:59 AM7/2/08
to
HI Phil, thanks for your help...

> Try to destroy RDM from outside of it (same level in where you created
it),

How? I don't know to do this. Because...
the httpsrvr.dll launches the RDM executable ( I'm using WebConnection on
the client);

I think that the RDM is created on the code below:

initialization
TComponentFactory.Create(ComServer, TMyRDM,
Class_MyRDM, ciMultiInstance, tmApartment);

But this source-code is on the RDM's unit...
I'm confused. Can you help me?

Ricardo.


"PhilDGS" <phi...@hotmail.com> escreveu na mensagem

news:486ac3e4$1...@newsgroups.borland.com...

PhilDGS

unread,
Jul 2, 2008, 9:46:25 AM7/2/08
to
Hi Ricardo;

That's sound much better !!!, because it's suposed RDM will be automatically
destroyed when you close the client connection. So, try to left it alone (I
mean, don't call your RDM.CloseMyConnection).

At least, I use DataSnap/Midas and RDMs are created/destroyed automatically
when each client connects/disconnects.

Phil


Alexandre Machado

unread,
Jul 3, 2008, 5:49:49 AM7/3/08
to
> How? I don't know to do this. Because...
> the httpsrvr.dll launches the RDM executable ( I'm using WebConnection on
> the client);

PhilDGS is right. Do NOT free your RDM manually, calling a remote method
from the client application.
Whenever you close the WebConnection (freeing it or closing it explicitly)
your RDM instance will be destroyed as well.

Try to put some OutputDebugString in OnDestroy event handler, like this:

procedure TMyRemoteDM.RemoteDataModuleDestroy(Sender: TObject);
begin
OutputDebugString(PChar(ClassName + '.Destroy'));
end;

You can play with it and see if it is being destroyed as you close the
connections.

PS: Use DebugView (http://download.sysinternals.com/Files/DebugView.zip) to
"catch" the OutputDebugString messages.

Regards.


Ricardo Carmo

unread,
Jul 3, 2008, 10:45:01 AM7/3/08
to
Alexandre and Phil,

I have discovered that the problem is in the client app.
My client app is a Windows Service. If I do connect to RDM from a Windows
App,
the RDM is destroyed after close connection, but if I connect from a Windows
Service,
the RDM is not destroyed. Any ideas?

Thanks.
Ricardo Carmo

"Alexandre Machado" <alexandre@f#ckspamconsultbrasil.com.br> escreveu na
mensagem news:486c...@newsgroups.borland.com...

Ricardo Carmo

unread,
Jul 3, 2008, 11:42:13 AM7/3/08
to
Dear friends,
I have discovered that:

1. If I disconnect from the RDM with no RDM methods called, the RDM is
destroyed.
2. If I call any method from the RDM, after disconnect the RDM does not
destroyed.

What's wrong?


Ricardo


"Alexandre Machado" <alexandre@f#ckspamconsultbrasil.com.br> escreveu na
mensagem news:486c...@newsgroups.borland.com...

PhilDGS

unread,
Jul 3, 2008, 2:14:31 PM7/3/08
to
Ricardo;

Opt. 1 is the right way. Simply disconnect the client and the server will
destroy the RDM alone.

Phil.


Ricardo Carmo

unread,
Jul 3, 2008, 3:56:09 PM7/3/08
to
Sorry, my english is poor. You don't understand what I sayd.

If app client connects to RDM and does not call a RDM's function or
procedure,
when it disconnects, the DRM is destroyed. That's ok.

But...

If app client connects to RDM and CALLS a RDM's function or procedure after
that,
when it disconnects, the RDM is not destroyed.

Do you undestand now?


"PhilDGS" <phi...@hotmail.com> escreveu na mensagem

news:486d...@newsgroups.borland.com...

Ricardo Carmo

unread,
Jul 3, 2008, 4:40:58 PM7/3/08
to
I just found the fix to the bug:

http://www.distribucon.com/midasbug/results.asp?DelphiVersion=11

This bug applies only to TWebConnection.

Thanks Phil.
Problem fixed.

Ricardo.

"Ricardo Carmo" <nwl...@yahoo.com.br> escreveu na mensagem

Ricardo Carmo

unread,
Jul 4, 2008, 9:25:11 AM7/4/08
to
Ok Alexandre, sua idéia de debugar o evento onDestroy serviu pra
constatar que o RDM não estava sendo destruído quando o cliente se
desconectava.
Eu encontrei na internet a explicação e a solução para este problema.
Tratava-se de um bug do Delphi 7 cuja solução foi apresentada no
link abaixo:

http://www.distribucon.com/midasbug/results.asp?DelphiVersion=11

Que bom que eu encontrei. Se não desse pra resolver, esta solução de
utilizar RDM via HTTP ficaria inviável.

De qualquer modo, obrigado.
Ricardo Carmo


"Alexandre Machado" <alexandre@f#ckspamconsultbrasil.com.br> escreveu na
mensagem news:486c...@newsgroups.borland.com...

0 new messages