community.borland.com

Article #25135: When does InterBase return allocated memory to the operating system?

Problem:
When InterBase allocates memory to perform operations, it does not ever
return this memory to the operating system.  This memory is returned to 
InterBase's internal memory free list, but it is never returned to the 
operating system for other processes to use.  Thus the memory is 
not freed until the InterBase service is stopped or the machine is 
rebooted.
  
Comparing V4.1 and V4.2.X 
---------------------------------------

[InterBase V4.1.0]
Versions V4.1 and earlier all used a server model called the "classic" 
model.  The classic model is one in which each connection is 
process-based.  This means that for each remote connection to a 
database on the server, a seperate process is started to handle that 
connection.  The memory problem was present in the classic model, 
but is less of a problem because of the process-based architecture.
When each connection terminates the process that was spawned for 
it also terminates.  The process' termination causes the memory that 
it allocated to be freed to the operating system.

[InterBase V4.2.x and V5.x]
Version V4.2.X introduced a new server model called "superserver".  
The superserver model is a thread-based approach.  This means 
that there is one process and a pool of threads to handle remote 
connections.  So, for each remote connection threads are used 
to manage the connection, opposed to a new process in the classic 
model.  The memory deallocation problem becomes more of an 
issue with the superserver model because of the server process never 
terminating.  When a connection terminates the associated thread is 
placed back in the thread pool or terminated.  However, neither of these 
actions affects the memory allocated, because memory allocation is 
process-based not thread-based.  

Note: Some v5.x platforms are still using the classic model.  Check the
release notes for details.


Solution:
The information in this article applies to:
  * InterBase v4.x
  * InterBase v5.x

To free the memory back to the operating system, the InterBase 
superserver process must be stopped and restarted.  This will 
cause the process to terminate thus releasing all allocated memory 
back to the operating system.  This can be achieved in two ways:

    1) actually stopping and restarting the service 
            A) Through the Control Panel | Services applet
            B) InterBase command line executable instsvc

    2) rebooting the server machine

Last Modified: 28-SEP-00