Consultor Eletrônico



Kbase P107650: 4GL program with client socket programming becomes slower and slower
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/16/2008
Status: Unverified

FACT(s) (Environment):

Progress 9.x
OpenEdge 10.x

SYMPTOM(s):

4GL program becomes slower and slower.

Using socket programming in 4GL.

4GL program uses the CREATE SOCKET <socket handle> statement.

4GL program uses client sockets.

No use of DELETE OBJECT <socket handle>.

No use of DELETE OBJECT SELF.

CAUSE:

4GL client sockets must be deleted explicitly when no longer needed.
Failure to do so makes it more and more "difficult" for Progress or OpenEdge to allocate new dynamic objects [such as new socket handles], which in turn causes the whole application to become slower and slower over time.

FIX:

Remember to delete excplicitly the 4GL client socket created with the CREATE SOCKET statement. This can be achieved in either of two ways:

1) Add a DELETE OBJECT <socket handle> statement after the handle is no longer needed, for example:

DEFINE VARIABLE hSocket AS HANDLE NO-UNDO.

CREATE SOCKET hSocket.
hSocket:CONNECT(...).
hSocket:SET-READ-RESPONSE-PROCEDURE(...).

WAIT-FOR <some event>.

DELETE OBJECT hSocket. /* <- Important! */

2) Add a DELETE OBJECT SELF in the read-response procedure, for example:

DEFINE VARIABLE hSocket AS HANDLE NO-UNDO.

CREATE SOCKET hSocket.
hSocket:CONNECT(...).
hSocket:SET-READ-RESPONSE-PROCEDURE("myReadResponse").

WAIT-FOR <some event>.

PROCEDURE myReadResponse:

IF SELF:CONNECTED() = NO THEN DO:
DELETE OBJECT SELF. /* <- Important! */
RETURN.
END.

...

END PROCEDURE.

Beware that with this second approach, the socket stored in hSocket will become invalid after the client socket has disconnected from the server.