We can control some lifecycle parameters in the deployment descriptor. For example, the following parameter allows us to control when an instance will be deactivated:
<parameter name="instance-deactivation" value="10000"/>
The time is expressed in milliseconds. After the instance has been idle for 10 seconds, it will be deactivated. Remember instances can be in an activated or deactivated state. Instances are created in a deactivated state (not loaded into memory), and are activated upon their first use. By default, they remain activated indefinitely. In some cases, it might be interesting to unload the instances after a certain time to save system resources. Of course, once the instance is invoked again, it will once again be activated.