Package org.jpox.util

Examples of org.jpox.util.ReferenceValueMap$ValueReference


    protected abstract ReferenceValueMap newReferenceValueMap();

    public void testMemoryReclamation()
    {
        ReferenceValueMap map = newReferenceValueMap();
        Runtime rt = Runtime.getRuntime();

        rt.gc();

        int added = 0;
        int size;
        long freeMem;

        /*
         * Fill the map with entries until some references get cleared.  GC
         * should cause references to be cleared well before memory fills up.
         */
        do
        {
            freeMem = rt.freeMemory();
            String key = "" + added;
            Object value = new Integer(added++);

            map.put(key, value);

            size = map.size();
        } while (size == added);

        assertTrue(size < added);

        LOG.info("ReferenceValueMap " + (added - size) + " entries out of " + added + " cleared when free memory was " + (int)(freeMem / 1024) + "KB");
View Full Code Here


    }


    public void testBasicFunction()
    {
        ReferenceValueMap map = newReferenceValueMap();
        String[] keyArray = new String[NUM_TEST_ENTRIES];
        Integer[] valueArray = new Integer[NUM_TEST_ENTRIES];

        for (int i = 0; i < keyArray.length; i++)
        {
            keyArray[i] = "" + i;
            valueArray[i] = new Integer(i);

            map.put(keyArray[i], valueArray[i]);
        }

        checkMapContents(map, keyArray, valueArray);

        Map map2 = (Map)map.clone();
        map.clear();

        assertEquals(0, map.size());

        map.putAll(map2);

        checkMapContents(map, keyArray, valueArray);

        assertEquals(NUM_TEST_ENTRIES, map.size());
    }
View Full Code Here

TOP

Related Classes of org.jpox.util.ReferenceValueMap$ValueReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.