United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-5043070 : Long time to restore minimized application

Details
Type:
Bug
Submit Date:
2004-05-06
Status:
Resolved
Updated Date:
2004-11-09
Project Name:
JDK
Resolved Date:
2004-06-16
Component:
client-libs
OS:
windows_xp
Sub-Component:
java.awt
CPU:
x86
Priority:
P2
Resolution:
Fixed
Affected Versions:
1.4.2
Fixed Versions:
5.0 (b56)

Related Reports

Sub Tasks

Description
When you minimize any other large Java app (like NetBeans IDE) that manages to be really idle
when minimized on Windows, it is totally swapped out, and once you switch to it, it is feeling
like a zombie for next few minutes.
###@###.### 2004-05-06
###@###.### 2004-05-07

                                    

Comments
EVALUATION

The time to restore a minimized Java GUI application has nothing at all to do with paging unless the system in question has insufficient main memory and other activiity on the system would cause the Java app's working set to be stolen away. But this effect would be noticeable whether or not the GUI was minimized. But more fundamentally Sun's J2SE implementation, at the VM level at least, has no mechanism for overriding the VM policy of the operating system and causing it's own working set to be "trimmed." There is also no means by which the VM can cause its pages to be swapped out: this behavior is imposed by the OS in response to other demands for virtual memmory.

Name: ssR10077			Date: 05/25/2004


Problem:
The time to restore a minimized Java GUI application has nothing at
all to do with paging unless the system in question has insufficient 
main memory and other activity on the system would cause the Java
app's working set to be stolen away. But this effect would be 
noticeable whether or not the GUI was minimized. But more 
fundamentally Sun's J2SE implementation, at the VM level at least, 
has no mechanism for overriding the VM policy of the operating system 
and causing it's own working set to be "trimmed." There is also no 
means by which the VM can cause its pages to be swapped out: this 
behavior is imposed by the OS in response to other demands for 
virtual memory.

Requesters:
Net Beans, ###@###.### 

Solution:
Make a system property to allow Java application disable the working set
trimming as described in MSKB article 293215. To do so application should
override the processing of WM_SYSCOMMAND (wParam == SC_MINIMIZE) and 
programmatically minimize the window.

The feature is turned off by default, so the behavior of unwilling
applications will not be changed.


Interface summary
exported private  other System property java.awt.trimWorkingSetOnMinimize

Specification

Microsoft Knowledge Base Article - 293215 PRB: An Application's Working 
Set Is Trimmed When Its Top-Level Window Is Minimized

is available on URL
http://support.microsoft.com/default.aspx?scid=kb;en-us;293215

sun.awt.keepWorkingSetOnMinimize
      if sun.awt.keepWorkingSetOnMinimize=="true", the working set
      trimming is disabled, otherwise the default OS behavior is 
      preserved.

Compatibility risk: minimal


======================================================================
###@###.### 2004-11-09 22:34:31 GMT
###@###.### 2004-11-09 22:35:42 GMT
###@###.### 2004-11-09 22:36:09 GMT
                                     
2004-11-09
SUGGESTED FIX

Do not trim working set of an application on minimize using similar approach as in Mozilla as described in http://bugzilla.mozilla.org/show_bug.cgi?id=76831
###@###.### 2004-05-06

Name: ssR10077			Date: 05/25/2004


*** /export/bino/t3/webrev/src/windows/classes/sun/awt/windows/WFramePeer.java- Thu Apr 29 20:08:49 2004
--- WFramePeer.java     Thu Apr 29 19:23:42 2004
--------------------------------------------------------------------------------
*** 31,40 ****
--- 31,50 ----
      // Convenience methods to save us from trouble of extracting
      // Rectangle fields in native code.
      private native void setMaximizedBounds(int x, int y, int w, int h);
      private native void clearMaximizedBounds();
      
+     private static boolean trimOnMinimize = true;
+ 
+     static {
+        String trim = System.getProperty("java.awt.trimWorkingSetOnMinimize","true");
+        System.out.println("java.awt.trimWorkingSetOnMinimize = " + trim);   
+        if (trim.equals("false")) {
+         trimOnMinimize = false;
+        }
+     }
+ 
      public void setMaximizedBounds(Rectangle b) {
        if (b == null) {
            clearMaximizedBounds();
        } else {
            setMaximizedBounds(b.x, b.y, b.width, b.height);

*** /export/bino/t3/webrev/src/windows/native/sun/windows/awt_Frame.cpp-        Thu Apr 29 20:08:50 2004
--- awt_Frame.cpp       Thu Apr 29 20:01:54 2004
--------------------------------------------------------------------------------
*** 938,948 ****
--- 938,962 ----
      return TRUE;
  
      CATCH_BAD_ALLOC_RET(FALSE);
  }
  
+ static BOOL trimChecked = FALSE; 
+ static BOOL trim = FALSE;
  
+ static BOOL trimOnMinimize(jobject peer) {
+     if (trimChecked == TRUE ) {
+         return trim;
+     }
+     else {
+         JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+         trim = ((JNU_GetStaticFieldByName(env, NULL, "sun/awt/windows/WFramePeer", "trimOnMinimize", "Z").z) == JNI_FALSE) ? FALSE : TRUE;
+         trimChecked = TRUE;
+     }
+     return  trim;
+ }
+ 
  MsgRouting AwtFrame::WmSysCommand(UINT uCmdType, int xPos, int yPos)
  {
      if (uCmdType == (SYSCOMMAND_IMM & 0xFFF0)){
        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
        if (env->EnsureLocalCapacity(2) < 0) {
--------------------------------------------------------------------------------
*** 951,960 ****
--- 965,980 ----
        JNU_CallMethodByName(env, NULL, m_peerObject, "notifyIMMOptionChange", 
                           "()V");
        DASSERT(!safe_ExceptionOccurred(env));  
        return mrConsume;
      }
+     if ((uCmdType == SC_MINIMIZE) && !trimOnMinimize(m_peerObject)) {
+         printf("Vetoing Trim on Minimize ");
+         fflush(stdout);
+         ::ShowWindow(GetHWnd(),SW_SHOWMINIMIZED);
+         return mrConsume; 
+     }
      return AwtWindow::WmSysCommand(uCmdType, xPos, yPos);
  }
  
  LRESULT AwtFrame::WinThreadExecProc(ExecuteArgs * args)
  {



======================================================================
                                     
2004-09-17
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger-rc

FIXED IN:
tiger-rc

INTEGRATED IN:
tiger-b56
tiger-rc


                                     
2004-09-17



Hardware and Software, Engineered to Work Together