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

TEST_BUG: j/l/management/MemoryMXBean/ResetPeakMemoryUsage fails with NegativeArraySizeException

    XMLWordPrintable

Details

    • b91
    • generic
    • generic
    • Not verified

    Backports

      Description

        The test java/lang/management/MemoryMXBean/ResetPeakMemoryUsage fails with NegativeArraySizeException:

        Selected memory pool:
            Memory Pool name: G1 Old Gen
            Type: Heap memory
            Memory Usage: init = 1696595968(1656832K) used = 0(0K) committed = 1696595968(1656832K) max = 32126271488(31373312K)
            Threshold: 0
            Manager = [G1 Old Generation]
        Before big object is allocated:
        Current Usage:
            Initial size = 1696595968 (1656832K)
            Used size = 0
            Committd size = 1696595968 (1656832K)
            Max size = 32126271488 (31373312K)
        Peak Usage:
            Initial size = 1696595968 (1656832K)
            Used size = 0
            Committd size = 1696595968 (1656832K)
            Max size = 32126271488 (31373312K)
        ----------System.err:(13/696)----------
        java.lang.NegativeArraySizeException
        at ResetPeakMemoryUsage.main(ResetPeakMemoryUsage.java:66)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at com.sun.javatest.regtest.MainWrapper$MainThread.run(MainWrapper.java:94)
        at java.lang.Thread.run(Thread.java:722)

        Looking at the test it's obvious why this happens:

                final long largeArraySize = (usage0.getMax() - usage0.getUsed()) / 10; <---- largeArraysSize ends up being 3212627148, well beyond MAX_INT

                // Allocate a big array - need to allocate from the old gen
                Object[][][] obj = new Object[1][1][(int) largeArraySize]; <--- Casting this to int results in -1082340148
        Not Critical and a test bug.
        Let's do it in 7u8.

        OK Dev / nloodin
        OK SQE / ctornqvi

        Attachments

          Issue Links

            Activity

              People

                sla Staffan Larsen (Inactive)
                ctornqvi Christian Tornqvist
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: