Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7173044

Memory monitor demo hangs the system if MemoryUsage obj returns -1 .

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 8
    • 7
    • core-svc

        A DESCRIPTION OF THE REQUEST :
        In MemoryMonitor.java: plotMemoryUsage method.

        This piece of code "
         MemoryPoolMXBean mp = mpools.get(npool);
         float usedMemory = mp.getUsage().getUsed();
         float totalMemory = mp.getUsage().getMax(); "

         is followed by

         "
         // .. Memory Free ..
         big.setColor(mfColor);
         int MemUsage = (int) (((totalMemory - usedMemory) / totalMemory) * 10);
         int i = 0;
         for ( ; i < MemUsage ; i++) {
                mfRect.setRect(x1+5,(float) y1+ssH+i*blockHeight,
                         blockWidth, blockHeight-1);
                big.fill(mfRect);
         }
        "

        If totalMemory is -1, MemUsage will become a very large value, and the demo hangs in the loop.

        In order to reproduce the problem, another jdk other than ri is required because these beans are jdk dependent. It can be reproduced using ibm jdk to run the MemoryMonitor demo.


        JUSTIFICATION :
        Spec says it is allowed for MemoryUsage.getMax to return -1 if the maximum memory size is undefined.


        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The demo is still working when MemoryUsage.getMax returns -1 .
        ACTUAL -
        The demo hangs.

              dholmes David Holmes
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: