Here are some ways to avoid memory leaks when designing your EAServer applications. Some points are more relevant to PowerBuilder applications and others to Java.
Stateful objects have a one-to-one relationship with the client, so if the client disconnects, the object persists until the server times out. Stateless objects are preferable.
Close database connections when finished; otherwise, the transaction manager cannot give connection resources to another requestor until a timeout occurs.
Keep variable scope as small as possible. Limit the use of instance variables. Even if a component instance is not currently active, its storage persists for the lifetime of the instance.
Use the appropriate event to create and destroy
objects. If stateful, create instance objects in the constructor
event and destroy them in the destructor event. If stateless, reset
instance objects in the activate and deactivate events. In the deactivate
event, set instance variables in Java components to null. When using DataStores in
PowerBuilder components, reset the DataWindowObject to an empty
string: ds.dataobject = “”
,
where ds is a data store reference to an instance
variable.
Minimize refreshing EAServer components and Web applications in production environments. Refreshing leaves the prior implementation loaded in memory, and excessive refreshing can overuse memory. When you do refresh components or Web applications in a production server, perform the refresh operation at the lowest level possible. For example, if you change one component, refresh that component only.
Never refresh a server in a production environment,
as this reloads all components and Web applications.
Destroy any objects you create; do not rely on the garbage collector.
Clean up after database activity, closing database connections and managing transactions to ensure correct life-cycle execution of components.
Set blobs to null when finished.