The management of server side objects in memory is tied to the client connections and the server objects life cycle setting. Server side objects are generally kept in memory until the connection is closed (Session) or until the server is closed (Server), regardless of any active connection.
The situation is different for the Invocation life cycle, as in this case the server side object (TStorageServerClass in the example) is created at every invocation and should be immediately destroyed. What happens, however, is that (in Delphi 2009 with the Update 1 installed) for every invocation of a server method there is a leak of the server side object. For example, using the Invocation life cycle in the program, creating a client connection, and calling a server method twice, produces the following error when the server is closed:
Unexpected Memory Leak -SI
An unexpected memory leak has occurred. The unexpected small block leaks are:
1 - 12 bytes: TStorageServerClass x2
To fix the problem you can manually free the server side object by handling the OnDestroylnstance event of the related DSServerClass component (which receives a single parameter, with a very long name and class name, with the server class information and the server class instance attached):
DSDestroylnstanceEventObject: TDSDestroylnstanceEventObject); begi n
Was this article helpful?
What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.