My Oracle Support Banner

How to Prevent Legacy Lifecycle Applets from Getting Destroyed Prematurely (Doc ID 1478444.1)

Last updated on MARCH 31, 2023

Applies to:

Java SE JDK and JRE - Version 6 to 8
Information in this document applies to any platform.

Goal

Applet2Manager and Plugin2Manager are the classes that manage the lifecycle of an applet. When you instantiate an applet, you typically get an Applet2Manager object. When legacy_lifecycle is set to true, this manager is cached in Applet2ManagerCache anytime the page that launched the applet goes out of context. When the user returns to the page (or launches a page that has same type of applet), the manager is retrieved from the Applet2ManagerCache and removed from the cache.

When a manager is added to the Applet2ManagerCache for the first time, a timer with a TimerTask called Watchdog is launched. The main purpose of the Watchdog task is to check "memoryPressure" (total memory vs max memory). Anytime it sees the ratio to be above 90% memory (heap) used and there is a manager in the cache, it initiates a destroy on the cached applet. The timer itself has a varying "period" when it can potentially launch Watchdog task.  If the memoryPressure ratio is below 50%, the period is 30 secs.  If below 75%, the period is 15 secs.  Anything above 75%, yields a period of 5 secs. This period is dynamically adjusted in Watchdog.

On Java 6 and 7, you may see the legacy_lifecycle cache get destroyed even though utilized heap is well below max heap and no OutOfMemory (OOM) condition is near.

For example, given a default maximum heap of 256m and a minimum heap of 64m, when heap usage gets close to 64m adaptive sizing expands totalHeap to 128m.  When heap usage gets close to 128m, adaptive sizing again resizes the heap to 256m, which puts totalHeap at 100% of maxHeap.  Even though actual heap usage is far below maxHeap (still at about 128m), the totalHeap (allocated heap) is now 100% of maxHeap and will trigger the WatchdogTask memoryPressure code to destroy all the applets in the legacy_lifecycle cache.

This behavior is mostly due to initial min/max heap sizing and the JVM's aggressive heap resizing algorithms, where the totalHeap, i.e. allocated heap, is doubled each time utilization reaches a certain threshold.  But you may also be affected by a bug in the WatchDogTask's memory pressure calculation which is based on totalHeap, rather than utilized heap.  See <Bug 14080741>.

This document provides guidance on avoiding the premature destruction of legacy_lifecycle applets from this condition.

Solution

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Goal
Solution
References


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.